From 5d7cba153f5d168b4415b3755e394ec837182d4c Mon Sep 17 00:00:00 2001 From: Sunwoo Song Date: Sat, 5 Aug 2023 20:44:50 +0900 Subject: [PATCH 1/2] upload: part1 quiz 2503 codes(cpp, py) --- .../2503.cpp" | 62 +++++++++++++++++++ .../2503.py" | 35 +++++++++++ 2 files changed, 97 insertions(+) create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.cpp" create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.py" diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.cpp" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.cpp" new file mode 100644 index 0000000..71ab0ff --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.cpp" @@ -0,0 +1,62 @@ +#include +#include +using namespace std; + +struct Query { + int num, strike, ball; +}; + +int main() +{ + int N; + scanf("%d", &N); + + vector vec(N); + for (int i = 0; i < N;i++) + scanf("%d %d %d", &vec[i].num, &vec[i].strike, &vec[i].ball); + + int ans = 0; + for (int x = 1; x <= 9; x++) + { + for (int y = 1; y <= 9; y++) + { + for (int z = 1; z <= 9; z++) + { + if (x == y || y == z || x == z) + continue; + bool psb = true; + for (int i = 0; i < N; i++) + { + int qx = vec[i].num / 100; + int qy = (vec[i].num / 10) % 10; + int qz = vec[i].num % 10; + + int strike = 0; + int ball = 0; + if (x == qx) + strike++; + else if (x == qy || x == qz) + ball++; + if (y == qy) + strike++; + else if (y == qx || y == qz) + ball++; + if (z == qz) + strike++; + else if (z == qx || z == qy) + ball++; + if (strike != vec[i].strike || ball != vec[i].ball) + { + psb = false; + break; + } + } + if (psb) + ans++; + } + } + } + + printf("%d\n", ans); + return 0; +} diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.py" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.py" new file mode 100644 index 0000000..5763648 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemB_\354\210\253\354\236\220\354\225\274\352\265\254/2503.py" @@ -0,0 +1,35 @@ +N = int(input()) +q = [list(map(int, input().split())) for _ in range(N)] + +ans = 0 +for x in range(1, 10): + for y in range(1, 10): + for z in range(1, 10): + if x == y or y == z or x == z: + continue + psb = True + for i in range(N): + qx = q[i][0] // 100 + qy = (q[i][0] // 10) % 10 + qz = q[i][0] % 10 + + strike, ball = 0, 0 + if x == qx: + strike += 1 + elif x == qy or x == qz: + ball += 1 + if y == qy: + strike += 1 + elif y == qx or y == qz: + ball += 1 + if z == qz: + strike += 1 + elif z == qx or z == qy: + ball += 1 + if strike != q[i][1] or ball != q[i][2]: + psb = False + break + if psb: + ans += 1 + +print(ans) From 2b8ed0f6e3ad2e3113249511b8c5040e6c702010 Mon Sep 17 00:00:00 2001 From: Sunwoo Song Date: Sat, 5 Aug 2023 20:59:54 +0900 Subject: [PATCH 2/2] upload: part1 quiz 15961 codes(cpp, py) --- .../15961.cpp" | 33 +++++++++++++++++++ .../15961.py" | 25 ++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.cpp" create mode 100644 "Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.py" diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.cpp" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.cpp" new file mode 100644 index 0000000..1008700 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.cpp" @@ -0,0 +1,33 @@ +#include +#include +#include +using namespace std; + +int main() +{ + int N, D, K, C; + scanf("%d %d %d %d", &N, &D, &K, &C); + + vector vec(N); + for (int i = 0; i < N; i++) + scanf("%d", &vec[i]); + + vector dish_count(D + 1); + int kind = 0; + for (int i = 0; i < K - 1; i++) + if (dish_count[dist[i]]++ == 0) + kind++; + + int ans = 0; + for (int i = 0; i < N; i++) + { + if (dish_count[dish[(i + K - 1) % N]]++ == 0) + kind++; + ans = max(ans, kind + (dish_count[C] == 0 ? 1 : 0)); + if (--dish_count[dish[i]] == 0) + kind--; + } + + printf("%d\n", ans); + return 0; +} diff --git "a/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.py" "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.py" new file mode 100644 index 0000000..ecdab61 --- /dev/null +++ "b/Part1_\352\260\225\354\235\230\354\236\220\353\243\214/Part1_\354\252\275\354\247\200\354\213\234\355\227\230/\353\254\270\354\240\234\353\263\204\354\275\224\353\223\234/ProblemD_\355\232\214\354\240\204\354\264\210\353\260\245/15961.py" @@ -0,0 +1,25 @@ +import sys +input = sys.stdin.readline + +N, D, K, C = map(int, input().split()) +dish = [int(input()) for _ in range(N)] +dish_count = [0] * (D + 1) +kind = 0 + +for i in range(K - 1): + if dish_count[dish[i]] == 0: + kind += 1 + dish_count[dish[i]] += 1 + +ans = 0 +for i in range(N): + if dish_count[dish[(i + K - 1) % N]] == 0: + kind += 1 + dish_count[dish[(i + K - 1) % N]] += 1 + ans = max(ans, kind + (1 if dish_count[C] == 0 else 0)) + + dish_count[dish[i]] -= 1 + if dish_count[dish[i]] == 0: + kind -= 1 + +print(ans)