From 70c4390e34022483f3d9506736f94bd7c4399beb Mon Sep 17 00:00:00 2001 From: TooYoungTooSimp <6648049+TooYoungTooSimp@users.noreply.github.com> Date: Wed, 17 Jul 2019 22:24:18 +0800 Subject: [PATCH] Wed, 17 Jul 2019 22:24:17 +0800 --- 20190601/CMakeLists.txt | 14 ++++ 20190601/P1.cpp | 11 +++ 20190601/P2.cpp | 56 +++++++++++++ 20190601/P3.cpp | 41 +++++++++ 20190601/P4.cpp | 22 +++++ 20190601/P5.cpp | 161 ++++++++++++++++++++++++++++++++++++ 20190601/P6.cpp | 32 +++++++ 20190601/P7.cpp | 9 ++ 20190601/P8.cpp | 56 +++++++++++++ C301717/CMakeLists.txt | 11 +++ C301717/P1.cpp | 47 +++++++++++ C301717/P2.cpp | 8 ++ C301717/P3.cpp | 54 ++++++++++++ C301717/P4.cpp | 9 ++ C301717/P5.cpp | 24 ++++++ C302167/CMakeLists.txt | 15 ++++ C302167/P1.cpp | 9 ++ C302167/P2.cpp | 8 ++ C302167/P3.cpp | 8 ++ C302167/P4.cpp | 8 ++ C302167/P5.cpp | 8 ++ C302167/P6.cpp | 8 ++ C302167/P7.cpp | 8 ++ C302167/P8.cpp | 8 ++ C302167/P9.cpp | 8 ++ C304367/CMakeLists.txt | 12 +++ C304367/P1.cpp | 23 ++++++ C304367/P2.cpp | 8 ++ C304367/P3.cpp | 8 ++ C304367/P4.cpp | 8 ++ C304367/P5.cpp | 8 ++ C304367/P6.cpp | 46 +++++++++++ C311684/CMakeLists.txt | 11 +++ C311684/Easy1.cpp | 22 +++++ C311684/Easy2.cpp | 23 ++++++ C311684/Extra.cpp | 6 ++ C311684/Hard1.cpp | 33 ++++++++ C311684/Hard2.cpp | 6 ++ C311684/Lunatic1.cpp | 6 ++ C311684/Lunatic2.cpp | 6 ++ C311684/Normal1.cpp | 22 +++++ C311684/Normal2.cpp | 10 +++ cf1167/CMakeLists.txt | 13 +++ cf1167/P1.cpp | 16 ++++ cf1167/P2.cpp | 27 ++++++ cf1167/P3.cpp | 33 ++++++++ cf1167/P4.cpp | 17 ++++ cf1167/P5.cpp | 8 ++ cf1167/P6.cpp | 8 ++ cf1167/P7.cpp | 8 ++ cf1173/CMakeLists.txt | 12 +++ cf1173/P1.cpp | 21 +++++ cf1173/P2.cpp | 42 ++++++++++ cf1173/P3.cpp | 48 +++++++++++ cf1173/P4.cpp | 8 ++ cf1173/P5.cpp | 8 ++ cf1173/P6.cpp | 8 ++ coj38/CMakeLists.txt | 19 +++++ coj38/P01.cpp | 23 ++++++ coj38/P02.cpp | 51 ++++++++++++ coj38/P03.cpp | 8 ++ coj38/P04.cpp | 8 ++ coj38/P05.cpp | 23 ++++++ coj38/P06.cpp | 8 ++ coj38/P07.cpp | 8 ++ coj38/P08.cpp | 8 ++ coj38/P09.cpp | 8 ++ coj38/P10.cpp | 8 ++ coj38/P11.cpp | 8 ++ coj38/P12.cpp | 8 ++ coj38/P13.cpp | 8 ++ jsk2350/CMakeLists.txt | 10 +++ jsk2350/P1.cpp | 54 ++++++++++++ jsk2350/P2.cpp | 27 ++++++ jsk2350/P3.cpp | 21 +++++ jsk2350/P4.cpp | 8 ++ jsk2351/CMakeLists.txt | 10 +++ jsk2351/P1.cpp | 21 +++++ jsk2351/P2.cpp | 34 ++++++++ jsk2351/P3.cpp | 34 ++++++++ jsk2351/P4.cpp | 32 +++++++ jsk2421/CMakeLists.txt | 19 +++++ jsk2421/P01.cpp | 8 ++ jsk2421/P02.cpp | 25 ++++++ jsk2421/P03.cpp | 34 ++++++++ jsk2421/P04.cpp | 8 ++ jsk2421/P05.cpp | 86 +++++++++++++++++++ jsk2421/P06.cpp | 8 ++ jsk2421/P07.cpp | 8 ++ jsk2421/P08.cpp | 8 ++ jsk2421/P09.cpp | 8 ++ jsk2421/P10.cpp | 59 +++++++++++++ jsk2421/P11.cpp | 8 ++ jsk2421/P12.cpp | 8 ++ jsk2421/P13.cpp | 8 ++ jsk2983/1.py | 0 jsk2983/2.py | 19 +++++ jsk2983/CMakeLists.txt | 13 +++ jsk2983/P01.cpp | 14 ++++ jsk2983/P02.cpp | 25 ++++++ jsk2983/P03.cpp | 36 ++++++++ jsk2983/P04.cpp | 30 +++++++ jsk2983/P05.cpp | 38 +++++++++ jsk2983/P06.cpp | 8 ++ jsk2983/P07.cpp | 8 ++ lanqiao/PREV/CMakeLists.txt | 2 +- lanqiao/PREV/PREV-09.cpp | 26 ++++++ 107 files changed, 2138 insertions(+), 1 deletion(-) create mode 100644 20190601/CMakeLists.txt create mode 100644 20190601/P1.cpp create mode 100644 20190601/P2.cpp create mode 100644 20190601/P3.cpp create mode 100644 20190601/P4.cpp create mode 100644 20190601/P5.cpp create mode 100644 20190601/P6.cpp create mode 100644 20190601/P7.cpp create mode 100644 20190601/P8.cpp create mode 100644 C301717/CMakeLists.txt create mode 100644 C301717/P1.cpp create mode 100644 C301717/P2.cpp create mode 100644 C301717/P3.cpp create mode 100644 C301717/P4.cpp create mode 100644 C301717/P5.cpp create mode 100644 C302167/CMakeLists.txt create mode 100644 C302167/P1.cpp create mode 100644 C302167/P2.cpp create mode 100644 C302167/P3.cpp create mode 100644 C302167/P4.cpp create mode 100644 C302167/P5.cpp create mode 100644 C302167/P6.cpp create mode 100644 C302167/P7.cpp create mode 100644 C302167/P8.cpp create mode 100644 C302167/P9.cpp create mode 100644 C304367/CMakeLists.txt create mode 100644 C304367/P1.cpp create mode 100644 C304367/P2.cpp create mode 100644 C304367/P3.cpp create mode 100644 C304367/P4.cpp create mode 100644 C304367/P5.cpp create mode 100644 C304367/P6.cpp create mode 100644 C311684/CMakeLists.txt create mode 100644 C311684/Easy1.cpp create mode 100644 C311684/Easy2.cpp create mode 100644 C311684/Extra.cpp create mode 100644 C311684/Hard1.cpp create mode 100644 C311684/Hard2.cpp create mode 100644 C311684/Lunatic1.cpp create mode 100644 C311684/Lunatic2.cpp create mode 100644 C311684/Normal1.cpp create mode 100644 C311684/Normal2.cpp create mode 100644 cf1167/CMakeLists.txt create mode 100644 cf1167/P1.cpp create mode 100644 cf1167/P2.cpp create mode 100644 cf1167/P3.cpp create mode 100644 cf1167/P4.cpp create mode 100644 cf1167/P5.cpp create mode 100644 cf1167/P6.cpp create mode 100644 cf1167/P7.cpp create mode 100644 cf1173/CMakeLists.txt create mode 100644 cf1173/P1.cpp create mode 100644 cf1173/P2.cpp create mode 100644 cf1173/P3.cpp create mode 100644 cf1173/P4.cpp create mode 100644 cf1173/P5.cpp create mode 100644 cf1173/P6.cpp create mode 100644 coj38/CMakeLists.txt create mode 100644 coj38/P01.cpp create mode 100644 coj38/P02.cpp create mode 100644 coj38/P03.cpp create mode 100644 coj38/P04.cpp create mode 100644 coj38/P05.cpp create mode 100644 coj38/P06.cpp create mode 100644 coj38/P07.cpp create mode 100644 coj38/P08.cpp create mode 100644 coj38/P09.cpp create mode 100644 coj38/P10.cpp create mode 100644 coj38/P11.cpp create mode 100644 coj38/P12.cpp create mode 100644 coj38/P13.cpp create mode 100644 jsk2350/CMakeLists.txt create mode 100644 jsk2350/P1.cpp create mode 100644 jsk2350/P2.cpp create mode 100644 jsk2350/P3.cpp create mode 100644 jsk2350/P4.cpp create mode 100644 jsk2351/CMakeLists.txt create mode 100644 jsk2351/P1.cpp create mode 100644 jsk2351/P2.cpp create mode 100644 jsk2351/P3.cpp create mode 100644 jsk2351/P4.cpp create mode 100644 jsk2421/CMakeLists.txt create mode 100644 jsk2421/P01.cpp create mode 100644 jsk2421/P02.cpp create mode 100644 jsk2421/P03.cpp create mode 100644 jsk2421/P04.cpp create mode 100644 jsk2421/P05.cpp create mode 100644 jsk2421/P06.cpp create mode 100644 jsk2421/P07.cpp create mode 100644 jsk2421/P08.cpp create mode 100644 jsk2421/P09.cpp create mode 100644 jsk2421/P10.cpp create mode 100644 jsk2421/P11.cpp create mode 100644 jsk2421/P12.cpp create mode 100644 jsk2421/P13.cpp create mode 100644 jsk2983/1.py create mode 100644 jsk2983/2.py create mode 100644 jsk2983/CMakeLists.txt create mode 100644 jsk2983/P01.cpp create mode 100644 jsk2983/P02.cpp create mode 100644 jsk2983/P03.cpp create mode 100644 jsk2983/P04.cpp create mode 100644 jsk2983/P05.cpp create mode 100644 jsk2983/P06.cpp create mode 100644 jsk2983/P07.cpp diff --git a/20190601/CMakeLists.txt b/20190601/CMakeLists.txt new file mode 100644 index 0000000..94c5a34 --- /dev/null +++ b/20190601/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) +add_executable(P5 P5.cpp) +add_executable(P6 P6.cpp) +add_executable(P7 P7.cpp) +add_executable(P8 P8.cpp) \ No newline at end of file diff --git a/20190601/P1.cpp b/20190601/P1.cpp new file mode 100644 index 0000000..27760e4 --- /dev/null +++ b/20190601/P1.cpp @@ -0,0 +1,11 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + long long n; + scanf("%lld", &n); + printf("%lld", n * n); + return 0; +} diff --git a/20190601/P2.cpp b/20190601/P2.cpp new file mode 100644 index 0000000..60098f2 --- /dev/null +++ b/20190601/P2.cpp @@ -0,0 +1,56 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int a[15], T, n, ans; +int c[15]; +set S; +int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } +void dfs(int st) +{ + ans = max(ans, st); + for (int i = 0; i < n; i++) + if (!S.count(a[i])) + { + bool flag = true; + for (int j = 0; j < st; j++) + if (gcd(a[i], c[j]) != 1) + flag = false; + if (flag) + { + S.insert(a[i]); + c[st] = a[i]; + dfs(st + 1); + S.erase(a[i]); + } + } +} +int main() +{ + int T; + scanf("%d", &T); + while (T--) + { + ans = 0; + scanf("%d", &n); + for (int i = 0; i < n; i++) scanf("%d", a + i); + //dfs(0); + for (int i = 0; i < (1 << n); i++) + { + bool flag = true; + for (int j = 0; j < n; j++) + for (int k = j + 1; k < n; k++) + if ((i & (1 << j)) && (i & (1 << k))) + if (gcd(a[j], a[k]) != 1) + flag = false; + if (flag) + { + int cnt = 0; + for (int x = i; x; x -= x & -x) cnt++; + ans = max(ans, cnt); + } + } + cout << ans << endl; + } + return 0; +} diff --git a/20190601/P3.cpp b/20190601/P3.cpp new file mode 100644 index 0000000..ed8b897 --- /dev/null +++ b/20190601/P3.cpp @@ -0,0 +1,41 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + int T; + scanf("%d", &T); + while (T--) + { + string s, t; + cin >> s >> t; + int sl = s.length(); + int tl = t.length(); + if (sl - 2 != tl) + { + puts("0"); + continue; + } + int cur = 0, cut = 0; + bool ok = 1; + for (int i = 0; i < sl; i++) + { + if (s[i] == t[cur]) + { + cur++; + continue; + } + else + { + cut++; + } + if (cut > 2) ok = 0; + } + if (ok && cut == 2) + puts("1"); + else + puts("0"); + } + return 0; +} diff --git a/20190601/P4.cpp b/20190601/P4.cpp new file mode 100644 index 0000000..8a0b76d --- /dev/null +++ b/20190601/P4.cpp @@ -0,0 +1,22 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + map M; + for (int i = 0; i < 18; i++) + { + int x; + scanf("%d", &x); + M[x]++; + } + for (auto &i : M) + if (i.first) + i.second %= 2; + int ans = 0; + for (auto &i : M) + ans += i.second; + cout << ans; + return 0; +} diff --git a/20190601/P5.cpp b/20190601/P5.cpp new file mode 100644 index 0000000..f4571e6 --- /dev/null +++ b/20190601/P5.cpp @@ -0,0 +1,161 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +#define R 3 +#define U 0 +#define D 1 +#define L 2 +using namespace std; +int nxt[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}}; +char mp[20][20]; +int n; +bool tex(int x, int y) +{ + if (x <= n && x >= 1 && y >= 1 && y <= n) + { + if (mp[x][y] != '#') + return true; + else + return false; + } + return false; +} +void tx(int x, int y) { + if (tex(x-1,y)&&mp[x-1][y]=='T') +} + +int main() +{ + + scanf("%d", &n); + int sx, sy, tx, ty; + for (int i = 1; i <= n; i++) + { + scanf("%s", mp[i]); + for (int j = n; j > 0; j--) + { + mp[i][j] = mp[i][j - 1]; + if (mp[i][j] == 'S') + { + sx = i; + sy = j; + } + if (mp[i][j] == 'T') + { + tx = i; + ty = j; + } + } + } + int nx = sx, ny = sy, tohe = R; + int wx = sx, wy = sy + 1; + while (mp[nx][ny] != 'T') + { + if (tohe == R) + { + if (tex(nx + 1, ny + 1) && tex(nx , ny+1) ) + { + printf("D"); + tohe = D; + nx = nx + 1; + ny = ny + 1; + } + else if (tex(nx, ny+1)) + { + printf("D"); + nx = nx + 1; + } + else if (tex(nx-1, ny)) + { + printf("D"); + tohe = U; + } + else + { + printf("D"); + tohe = L; + } + + + } + + else if (tohe == U) + { + if (tex(nx - 1, ny + 1) && tex(nx - 1, ny) ) + { + printf("R"); + tohe = D; + nx = nx - 1; + ny = ny + 1; + } + else if (tex(nx - 1, ny)) + { + printf("R"); + nx = nx - 1; + } + else if (tex(nx, ny - 1)) + { + printf("R"); + tohe = L; + } + else + { + printf("R"); + tohe = D; + } + } + + else if (tohe == L) + { + if (tex(nx - 1, ny - 1) && tex(nx, ny-1) ) + { + printf("U"); + tohe = U; + nx = nx - 1; + ny = ny - 1; + } + else if (tex(nx, ny-1)) + { + printf("U"); + ny = ny - 1; + } + else if (tex(nx+1, ny)) + { + printf("U"); + tohe = D; + } + else + { + printf("U"); + tohe = R; + } + } + + else if (tohe == D) + { + if (tex(nx + 1, ny - 1) && tex(nx + 1, ny) ) + { + printf("L"); + tohe = L; + nx = nx + 1; + ny = ny - 1; + } + else if (tex(nx + 1, ny)) + { + printf("L"); + nx = nx + 1; + } + else if (tex(nx, ny + 1)) + { + printf("L"); + tohe = R; + } + else + { + printf("L"); + tohe = U; + } + } + } + return 0; +} diff --git a/20190601/P6.cpp b/20190601/P6.cpp new file mode 100644 index 0000000..b818c66 --- /dev/null +++ b/20190601/P6.cpp @@ -0,0 +1,32 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1e6 + 50; +pair a[N]; +int main() +{ + int n, m, q; + scanf("%d%d%d", &n, &m, &q); + int cnt = 0; + for (int i = 1; i < n; i++) + for (int j = 1; j < m; j++) + a[cnt++] = {i, j}; + set> S{a, a + cnt}; + while (q--) + { + int x, y; + scanf("%d%d", &x, &y); + decltype(S)::iterator ite; + ite = S.find(make_pair(x, y)); + if (ite != S.end()) S.erase(ite); + ite = S.find(make_pair(x - 1, y)); + if (ite != S.end()) S.erase(ite); + ite = S.find(make_pair(x, y - 1)); + if (ite != S.end()) S.erase(ite); + ite = S.find(make_pair(x - 1, y - 1)); + if (ite != S.end()) S.erase(ite); + printf("%lld\n", S.size()); + } + return 0; +} diff --git a/20190601/P7.cpp b/20190601/P7.cpp new file mode 100644 index 0000000..1c5a87e --- /dev/null +++ b/20190601/P7.cpp @@ -0,0 +1,9 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + + return 0; +} diff --git a/20190601/P8.cpp b/20190601/P8.cpp new file mode 100644 index 0000000..224ec77 --- /dev/null +++ b/20190601/P8.cpp @@ -0,0 +1,56 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 2e5 + 50; +int a[N]; +int main() +{ + /* int n; + scanf("%d", &n); + for (int i = 1; i <= n; i++) + scanf("%d", a + i); + a[0] = a[n + 1] = 0x3f3f3f3f; + int cnt = 0; + for (int i = 1; i <= n; i++) + if (a[i - 1] <= a[i] && a[i] >= a[i + 1]) + cnt++; + cout << cnt; + return 0;*/ + int n; + scanf("%d", &n); + int d = 0, last = 2147483640, os = 1; + for (int i = 1; i <= n; i++) + { + int s; + scanf("%d", &s); + if (os == 1) + { + if (last > s) + { + last = s; + } + else + { + os = 2; + last = s; + d++; + continue; + } + } + else if (os == 2) + { + if (last < s) + { + last = s; + } + else + { + os = 1; + last = s; + } + } + } + printf("%d\n", d); + return 0; +} diff --git a/C301717/CMakeLists.txt b/C301717/CMakeLists.txt new file mode 100644 index 0000000..966366e --- /dev/null +++ b/C301717/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus /wd6031") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) +add_executable(P5 P5.cpp) \ No newline at end of file diff --git a/C301717/P1.cpp b/C301717/P1.cpp new file mode 100644 index 0000000..817452c --- /dev/null +++ b/C301717/P1.cpp @@ -0,0 +1,47 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1e5 + 50; +int a1[N], a2[N], b1[N], b2[N], a[N], b[N]; +int main() +{ + int T, n, m; + scanf("%d", &T); + while (T--) + { + int ca1 = 0, ca2 = 0, cb1 = 0, cb2 = 0; + scanf("%d%d", &n, &m); + for (int i = 0; i < n; i++) scanf("%d", a + i); + for (int i = 0; i < m; i++) scanf("%d", b + i); + for (int i = 0, x; i < n; i++) + { + scanf("%d", &x); + if (x) + a1[ca1++] = a[i]; + else + a2[ca2++] = a[i]; + } + for (int i = 0, x; i < m; i++) + { + scanf("%d", &x); + if (x) + b1[cb1++] = b[i]; + else + b2[cb2++] = b[i]; + } + sort(a1, a1 + ca1); + sort(a2, a2 + ca2); + sort(b1, b1 + cb1); + sort(b2, b2 + cb2); + int ans = 0; + for (int i = 0, j = 0; i < ca1 && j < cb2; j++) + if (a1[i] < b2[j]) + ans++, i++; + for (int i = 0, j = 0; i < cb1 && j < ca2; j++) + if (b1[i] < a2[j]) + ans++, i++; + printf("%d\n", ans); + } + return 0; +} diff --git a/C301717/P2.cpp b/C301717/P2.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C301717/P2.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C301717/P3.cpp b/C301717/P3.cpp new file mode 100644 index 0000000..17bef7b --- /dev/null +++ b/C301717/P3.cpp @@ -0,0 +1,54 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +char s[256]; +char mp[2005][2005]; +inline int t(int i, int j) { return mp[i][j] - '0'; } +inline int nxt(int i, int j) { return (((t(i, j) * 3 + t(i - 1, j)) * 3 + t(i + 1, j)) * 3 + t(i, j - 1)) * 3 + t(i, j + 1); } +int vis[2005][2005]; +int main() +{ + int T, n, m, a, b; + ll k; + scanf("%d", &T); + while (T--) + { + scanf("%d%d%d%d%lld%s", &n, &m, &a, &b, &k, s); + a--, b--; + int ans = 0; + for (int i = 0; i < n; i++) scanf("%s", mp + i); + k = min(k, 2000ll * n * m); + while (k--) + { + //printf("** %d %d\n", a, b); + char op = s[nxt(a, b)]; + switch (op) + { + case 'U': + if (t(a - 1, b) != 1) a--; + break; + case 'D': + if (t(a + 1, b) != 1) a++; + break; + case 'L': + if (t(a, b - 1) != 1) b--; + break; + case 'R': + if (t(a, b + 1) != 1) b++; + break; + case 'P': + if (mp[a][b] == '2') ans++; + mp[a][b] = '0'; + break; + case 'I': + break; + default: + break; + } + } + printf("%d\n", ans); + } + return 0; +} diff --git a/C301717/P4.cpp b/C301717/P4.cpp new file mode 100644 index 0000000..66a132a --- /dev/null +++ b/C301717/P4.cpp @@ -0,0 +1,9 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + puts("UDRUDRLLRLLRUDRLLRDDRDDRLLRRDRRDRLLRLDRUDRLLRDDRDDRLLRUURUURLLRUURUURLLRDDRDDRLLRIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"); + return 0; +} \ No newline at end of file diff --git a/C301717/P5.cpp b/C301717/P5.cpp new file mode 100644 index 0000000..0be1150 --- /dev/null +++ b/C301717/P5.cpp @@ -0,0 +1,24 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 105; +long long a[N], b[N]; +int main() +{ + int T, n; + scanf("%d", &T); + while (T--) + { + scanf("%d", &n); + for (int i = n - 1; i >= 0; i--) scanf("%lld", a + i); + for (int i = n - 1; i >= 0; i--) scanf("%lld", b + i); + for (int i = 1; i < n; i++) a[i] += a[i - 1], b[i] += b[i - 1]; + bool flag = true; + for (int i = 0; i < n; i++) + if (a[i] > b[i]) + flag = false; + puts(flag ? "Yes" : "No"); + } + return 0; +} diff --git a/C302167/CMakeLists.txt b/C302167/CMakeLists.txt new file mode 100644 index 0000000..ece65f1 --- /dev/null +++ b/C302167/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) +add_executable(P5 P5.cpp) +add_executable(P6 P6.cpp) +add_executable(P7 P7.cpp) +add_executable(P8 P8.cpp) +add_executable(P9 P9.cpp) \ No newline at end of file diff --git a/C302167/P1.cpp b/C302167/P1.cpp new file mode 100644 index 0000000..1c5a87e --- /dev/null +++ b/C302167/P1.cpp @@ -0,0 +1,9 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + + return 0; +} diff --git a/C302167/P2.cpp b/C302167/P2.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P2.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P3.cpp b/C302167/P3.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P3.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P4.cpp b/C302167/P4.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P4.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P5.cpp b/C302167/P5.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P5.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P6.cpp b/C302167/P6.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P6.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P7.cpp b/C302167/P7.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P7.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P8.cpp b/C302167/P8.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P8.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C302167/P9.cpp b/C302167/P9.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C302167/P9.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C304367/CMakeLists.txt b/C304367/CMakeLists.txt new file mode 100644 index 0000000..d57b3ad --- /dev/null +++ b/C304367/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus" "/wd6031") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) +add_executable(P5 P5.cpp) +add_executable(P6 P6.cpp) \ No newline at end of file diff --git a/C304367/P1.cpp b/C304367/P1.cpp new file mode 100644 index 0000000..63c7bb8 --- /dev/null +++ b/C304367/P1.cpp @@ -0,0 +1,23 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + int T, x, y, a, b; + cin >> T; + while (T--) + { + cin >> x >> y >> a >> b; + if ((x == 1 && a >= 1) || (y == 1 && b >= 1) || ((x == 2 && y == 2 && a + b >= 3))) + puts("INF"); + else + { + int cnt = 0; + for (int c1 = a, c2 = b, tmp; c1 >= x || c2 >= y; c1 = c1 % x + tmp, c2 = c2 % y + tmp) + cnt += (tmp = c1 / x + c2 / y); + printf("%d\n", cnt); + } + } + return 0; +} diff --git a/C304367/P2.cpp b/C304367/P2.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C304367/P2.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C304367/P3.cpp b/C304367/P3.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C304367/P3.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C304367/P4.cpp b/C304367/P4.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C304367/P4.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C304367/P5.cpp b/C304367/P5.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/C304367/P5.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/C304367/P6.cpp b/C304367/P6.cpp new file mode 100644 index 0000000..a493fa0 --- /dev/null +++ b/C304367/P6.cpp @@ -0,0 +1,46 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +template +using cr = const T &; +struct p +{ + int l, r, id; +} a[50050]; +bool cmp(cr

l, cr

r) +{ + return l.l == r.l ? l.r < r.r : l.l < r.l; +} +bool cmp2(cr

l, cr

r) +{ + return l.r == r.r ? l.l < r.l : l.r > r.r; +} +int ans[50050]; +int main() +{ + int T, n; + scanf("%d", &T); + while (T--) + { + scanf("%d", &n); + for (int i = 0; i < n; i++) + scanf("%d%d", &a[i].l, &a[i].r), a[i].id = i + 1; + sort(a, a + n, cmp); + int cnt = 0; + p ps[3] = {a[0], a[1]}; + for (int i = 2; i < n; i++) + { + ps[2] = a[i]; + sort(ps, ps + 3, cmp); + bool f = ps[1].l <= ps[0].r && ps[2].l <= ps[0].r && ps[2].l <= ps[1].r; + sort(ps, ps + 3, cmp2); + if (f) ans[cnt++] = ps[0].id, swap(ps[0], ps[2]); + } + sort(ans, ans + cnt); + printf("%d\n", cnt); + for (int i = 0; i < cnt; i++) printf("%d ", ans[i]); + putchar('\n'); + } + return 0; +} \ No newline at end of file diff --git a/C311684/CMakeLists.txt b/C311684/CMakeLists.txt new file mode 100644 index 0000000..877e2a6 --- /dev/null +++ b/C311684/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0) +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(Easy1 Easy1.cpp) +add_executable(Easy2 Easy2.cpp) +add_executable(Extra Extra.cpp) +add_executable(Hard1 Hard1.cpp) +add_executable(Hard2 Hard2.cpp) +add_executable(Lunatic1 Lunatic1.cpp) +add_executable(Lunatic2 Lunatic2.cpp) +add_executable(Normal1 Normal1.cpp) +add_executable(Normal2 Normal2.cpp) diff --git a/C311684/Easy1.cpp b/C311684/Easy1.cpp new file mode 100644 index 0000000..fc6976e --- /dev/null +++ b/C311684/Easy1.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; +int a[105]; +int main() +{ + int T, n, V, W; + scanf("%d", &T); + while (T--) + { + scanf("%d%d%d", &n, &V, &W); + for (int i = 0; i < n; i++) scanf("%d", a + i); + sort(a, a + n); + int sum = 0, cnt = 0; + while (sum + a[cnt] <= W * (cnt + 1) && cnt < n) + sum += a[cnt++]; + if (cnt == 0) + puts("0 0.00"); + else + printf("%d %.2lf\n", cnt * V, 0.01 * sum / cnt); + } + return 0; +} \ No newline at end of file diff --git a/C311684/Easy2.cpp b/C311684/Easy2.cpp new file mode 100644 index 0000000..424250b --- /dev/null +++ b/C311684/Easy2.cpp @@ -0,0 +1,23 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1e5 + 50; +char s[N]; +void die(int x) +{ + puts(x ? "YES" : "NO"); + exit(0); +} +int main() +{ + int T; + scanf("%d", &T); + while (T--) + { + int n; + scanf("%d%s", &n, &s); + puts(find(s, s + n, '8') <= s + n - 11 ? "YES" : "NO"); + } + return 0; +} \ No newline at end of file diff --git a/C311684/Extra.cpp b/C311684/Extra.cpp new file mode 100644 index 0000000..3b74c4d --- /dev/null +++ b/C311684/Extra.cpp @@ -0,0 +1,6 @@ +#include +using namespace std; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/C311684/Hard1.cpp b/C311684/Hard1.cpp new file mode 100644 index 0000000..fb48e7e --- /dev/null +++ b/C311684/Hard1.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; +typedef long long ll; +const int N = 1e5 + 50; +ll a[N]; +int main() +{ + int T, n, k, ans; + scanf("%d", &T); + for (int t = 1; t <= T; t++) + { + scanf("%d%d", &n, &k); + for (int i = 0; i < n; i++) scanf("%lld", a + i); + ll sum = accumulate(a, a + n, 0ll); + if (sum % k) + ans = -1; + else + { + ll tgt = sum / k, cur = 0; + ans = -1; + deque D(a, a + n); + while (!D.empty()) + { + int cur = 0; + while (cur < tgt && !D.empty()) + cur += D.front(), D.pop_front(), ans++; + if (cur > tgt) D.push_front(cur - tgt), ans++; + } + } + printf("Case #%d: %d\n", t, ans); + } + return 0; +} \ No newline at end of file diff --git a/C311684/Hard2.cpp b/C311684/Hard2.cpp new file mode 100644 index 0000000..3b74c4d --- /dev/null +++ b/C311684/Hard2.cpp @@ -0,0 +1,6 @@ +#include +using namespace std; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/C311684/Lunatic1.cpp b/C311684/Lunatic1.cpp new file mode 100644 index 0000000..3b74c4d --- /dev/null +++ b/C311684/Lunatic1.cpp @@ -0,0 +1,6 @@ +#include +using namespace std; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/C311684/Lunatic2.cpp b/C311684/Lunatic2.cpp new file mode 100644 index 0000000..3b74c4d --- /dev/null +++ b/C311684/Lunatic2.cpp @@ -0,0 +1,6 @@ +#include +using namespace std; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/C311684/Normal1.cpp b/C311684/Normal1.cpp new file mode 100644 index 0000000..189c2b6 --- /dev/null +++ b/C311684/Normal1.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; +const int N = 105; +char s[N]; +int main() +{ + int n, cnt, ans; + while (~scanf("%d%s", &n, s)) + { + cnt = ans = 0; + for (int i = 0; i <= n; i++) + if (s[i] == 'x') + cnt++; + else + { + ans += max(0, cnt - 2); + cnt = 0; + } + printf("%d\n", ans); + } + return 0; +} \ No newline at end of file diff --git a/C311684/Normal2.cpp b/C311684/Normal2.cpp new file mode 100644 index 0000000..70c38fe --- /dev/null +++ b/C311684/Normal2.cpp @@ -0,0 +1,10 @@ +#include +using namespace std; +int main() +{ + int n, x, mx = 0; + scanf("%d", &n); + for (int i = 0; i < n; i++) scanf("%d", &x), mx = max(mx, x); + printf("%d", max(0, mx - 25)); + return 0; +} \ No newline at end of file diff --git a/cf1167/CMakeLists.txt b/cf1167/CMakeLists.txt new file mode 100644 index 0000000..b3c8c5c --- /dev/null +++ b/cf1167/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) +add_executable(P5 P5.cpp) +add_executable(P6 P6.cpp) +add_executable(P7 P7.cpp) \ No newline at end of file diff --git a/cf1167/P1.cpp b/cf1167/P1.cpp new file mode 100644 index 0000000..8d9a61a --- /dev/null +++ b/cf1167/P1.cpp @@ -0,0 +1,16 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +char s[1050]; +int main() +{ + int T, n; + scanf("%d", &T); + while (T--) + { + scanf("%d%s", &n, s); + puts((s + n - find(s, s + n, '8') > 10) ? "YES" : "NO"); + } + return 0; +} diff --git a/cf1167/P2.cpp b/cf1167/P2.cpp new file mode 100644 index 0000000..4dfd86b --- /dev/null +++ b/cf1167/P2.cpp @@ -0,0 +1,27 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + puts("? 1 2"); + puts("? 2 3"); + puts("? 4 5"); + puts("? 5 6"); + fflush(stdout); + int a[] = {4, 8, 15, 16, 23, 42}; + int a12, a23, a45, a56; + scanf("%d%d%d%d", &a12, &a23, &a45, &a56); + do + if (a[0] * a[1] == a12 && + a[1] * a[2] == a23 && + a[3] * a[4] == a45 && + a[4] * a[5] == a56) + { + printf("! %d %d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4], a[5]); + fflush(stdout); + break; + } + while (next_permutation(a, a + 6)); + return 0; +} diff --git a/cf1167/P3.cpp b/cf1167/P3.cpp new file mode 100644 index 0000000..972db7c --- /dev/null +++ b/cf1167/P3.cpp @@ -0,0 +1,33 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 5e5 + 50; +int fa[N], sz[N]; +int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } +void link(int x, int y) +{ + int fx = find(x), fy = find(y); + if (fx != fy) + { + fa[fy] = fx; + sz[fx] += sz[fy]; + } +} +int main() +{ + for (int i = 0; i < N; i++) fa[i] = i, sz[i] = 1; + int n, m; + scanf("%d%d", &n, &m); + for (int i = 0, c, s; i < m; i++) + { + scanf("%d", &c); + if (c == 0) continue; + scanf("%d", &s); + for (int i = 1, x; i < c; i++) + scanf("%d", &x), link(s, x); + } + for (int i = 1; i <= n; i++) + printf("%d ", sz[find(i)]); + return 0; +} diff --git a/cf1167/P4.cpp b/cf1167/P4.cpp new file mode 100644 index 0000000..eacd577 --- /dev/null +++ b/cf1167/P4.cpp @@ -0,0 +1,17 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 2e5 + 50; +char s[N]; +int c[N]; +int main() +{ + int n; + scanf("%d%s", &n, s); + for (int i = 0; i < n; i++) c[i + (s[i] == ')')] += (s[i] == '(') * 2 - 1; + for (int i = 1; i < n; i++) c[i] += c[i - 1]; + int th = *max_element(c, c + n) / 2; + for (int i = 0; i < n; i++) putchar('0' + (c[i] > th)); + return 0; +} diff --git a/cf1167/P5.cpp b/cf1167/P5.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/cf1167/P5.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/cf1167/P6.cpp b/cf1167/P6.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/cf1167/P6.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/cf1167/P7.cpp b/cf1167/P7.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/cf1167/P7.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/cf1173/CMakeLists.txt b/cf1173/CMakeLists.txt new file mode 100644 index 0000000..504c5f5 --- /dev/null +++ b/cf1173/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) +add_executable(P5 P5.cpp) +add_executable(P6 P6.cpp) \ No newline at end of file diff --git a/cf1173/P1.cpp b/cf1173/P1.cpp new file mode 100644 index 0000000..a05fbde --- /dev/null +++ b/cf1173/P1.cpp @@ -0,0 +1,21 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + int a, b, c; + scanf("%d%d%d", &a, &b, &c); + if (a == b && c == 0) + puts("0"); + else + { + if (a + c < b) + puts("-"); + else if (b + c < a) + puts("+"); + else + puts("?"); + } + return 0; +} diff --git a/cf1173/P2.cpp b/cf1173/P2.cpp new file mode 100644 index 0000000..338e98d --- /dev/null +++ b/cf1173/P2.cpp @@ -0,0 +1,42 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + int n; + scanf("%d", &n); + printf("%d\n", n / 2 + 1); + int x = 1, y = 1; + for (int i = 1; i <= n; i++) { + printf("%d %d\n", x, y); + (y == n / 2 + 1 ? x : y)++; + } + return 0; + if (n & 1) + { + printf("%d\n", n / 2 + 1); + for (int i = 1; i <= n / 2 + 1; i++) + printf("%d %d\n", 1, i); + for (int i = n / 2 + 1 + 1; i <= n; i++) + printf("%d %d\n", i - n / 2 - 1, n / 2 + 1); + } + else + { + printf("%d\n", n / 2 + 1); + for (int i = 1; i <= n / 2 + 1; i++) + printf("%d %d\n", 1, i); + for (int i = n / 2 + 1 + 1; i <= n; i++) + printf("%d %d\n", i - n / 2 - 1, n / 2 + 1); + } + return 0; + if (n == 1) + { + puts("1\n1 1"); + return 0; + } + printf("%d\n", ((n + 1) >> 1) + 1 - (n & 1)); + for (int i = 1; i <= n; i++) + printf("%d %d\n", (i + 1) >> 1, ((i + 1) >> 1) + 1 - (i & 1)); + return 0; +} diff --git a/cf1173/P3.cpp b/cf1173/P3.cpp new file mode 100644 index 0000000..2bd1e15 --- /dev/null +++ b/cf1173/P3.cpp @@ -0,0 +1,48 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 2e5 + 50; +int a[N], b[N]; +int main() +{ + int n; + scanf("%d", &n); + for (int i = 0; i < n; i++) scanf("%d", a + i); + for (int i = 0; i < n; i++) scanf("%d", b + i); + multiset A{a, a + n}, B{b, b + n}; + deque q{b, b + n}; + int zcnt = count(b, b + n, 0); + int opcnt = 0; + while (zcnt) + { + for (auto i : q) + printf("%2d ", i); + puts(""); + if (A.count(q.back() + 1)) + { + A.erase(q.back() + 1); + q.push_back(q.back() + 1); + B.insert(q.back() + 1); + if (q.front() == 0) zcnt--; + A.insert(q.front()); + B.erase(q.front()); + q.pop_front(); + opcnt++; + } + else + { + A.erase(A.begin()); + q.push_back(0); + B.insert(0); + zcnt++; + if (q.front() == 0) zcnt--; + A.insert(q.front()); + B.erase(q.front()); + q.pop_front(); + opcnt++; + } + } + printf("%d", opcnt); + return 0; +} diff --git a/cf1173/P4.cpp b/cf1173/P4.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/cf1173/P4.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/cf1173/P5.cpp b/cf1173/P5.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/cf1173/P5.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/cf1173/P6.cpp b/cf1173/P6.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/cf1173/P6.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/CMakeLists.txt b/coj38/CMakeLists.txt new file mode 100644 index 0000000..997e2ff --- /dev/null +++ b/coj38/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P01 P01.cpp) +add_executable(P02 P02.cpp) +add_executable(P03 P03.cpp) +add_executable(P04 P04.cpp) +add_executable(P05 P05.cpp) +add_executable(P06 P06.cpp) +add_executable(P07 P07.cpp) +add_executable(P08 P08.cpp) +add_executable(P09 P09.cpp) +add_executable(P10 P10.cpp) +add_executable(P11 P11.cpp) +add_executable(P12 P12.cpp) +add_executable(P13 P13.cpp) \ No newline at end of file diff --git a/coj38/P01.cpp b/coj38/P01.cpp new file mode 100644 index 0000000..d319581 --- /dev/null +++ b/coj38/P01.cpp @@ -0,0 +1,23 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 505, M = N * N; +int a[N], b[M]; +int main() +{ + int n, k; + scanf("%d%d", &n, &k); + for (int i = 0; i < n; i++) + scanf("%d", a + i); + int cnt = 0; + for (int i = 0; i < n; i++) + for (int j = i + 1; j < n; j++) + b[cnt++] = a[i] + a[j]; + sort(b, b + cnt); + long long ans = 0; + for (int i = cnt - k; i < cnt; i++) + ans += b[i]; + printf("%lld", ans); + return 0; +} diff --git a/coj38/P02.cpp b/coj38/P02.cpp new file mode 100644 index 0000000..d5d4a72 --- /dev/null +++ b/coj38/P02.cpp @@ -0,0 +1,51 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1e5 + 50; +int a[2][N]; +int vis[2][N]; +pair que[N]; +int rmost(int x) +{ + int h = 0, t = 0, ans = x; + for (que[t++] = {!a[0][x], x}; h ^ t; h++) + { + auto x = que[h]; + ans = max(ans, x.second); + if (a[x.first][x.second + 1]) que[t++] = {x.first, x.second + 1}, vis[x.first][x.second + 1] = true; + if (a[!x.first][x.second] && !vis[!x.first][x.second]) que[t++] = {!x.first, x.second}, vis[!x.first][x.second] = true; + } + return ans; +} +int main() +{ + int n; + scanf("%d", &n); + for (int i = 0; i < n; i++) + scanf("%d", &a[0][i]); + for (int i = 0; i < n; i++) + scanf("%d", &a[1][i]); + int l = 0, r = n; + while (a[0][l] == 0 && a[1][l] == 0) l++; + while (a[0][r] == 0 && a[1][r] == 0) r--; + int ans = 0; + while (l < r) + { + int t = rmost(l), t2; + if (t == r) break; + for (t2 = t + 1; t2; t2++) + if (a[0][t2] | a[1][t2]) + break; + if ((a[0][t] == 1 && a[0][t2] == 1) || (a[1][t] == 1 && a[1][t2] == 1)) + ans += t2 - t - 1; + else + { + ans += t2 - t; + a[0][t2] = a[1][t2] = 1; + } + l = t2; + } + printf("%d", ans); + return 0; +} \ No newline at end of file diff --git a/coj38/P03.cpp b/coj38/P03.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P03.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P04.cpp b/coj38/P04.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P04.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P05.cpp b/coj38/P05.cpp new file mode 100644 index 0000000..59ea9c8 --- /dev/null +++ b/coj38/P05.cpp @@ -0,0 +1,23 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + int T; + scanf("%d", &T); + while (T--) + { + long long a, b, x, cnt = 0; + scanf("%lld%lld%lld", &x, &a, &b); + for (long long i = 1; i <= a; i++) + for (long long j = 1; j <= b; j++) + if (x / i * j == x * j / i) + { + printf("dbg: %lld %lld %lld %lld\n", x, i, j, x / i * j); + cnt++; + } + printf("%lld\n", cnt); + } + return 0; +} \ No newline at end of file diff --git a/coj38/P06.cpp b/coj38/P06.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P06.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P07.cpp b/coj38/P07.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P07.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P08.cpp b/coj38/P08.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P08.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P09.cpp b/coj38/P09.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P09.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P10.cpp b/coj38/P10.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P10.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P11.cpp b/coj38/P11.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P11.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P12.cpp b/coj38/P12.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P12.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/coj38/P13.cpp b/coj38/P13.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/coj38/P13.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2350/CMakeLists.txt b/jsk2350/CMakeLists.txt new file mode 100644 index 0000000..c190f81 --- /dev/null +++ b/jsk2350/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) \ No newline at end of file diff --git a/jsk2350/P1.cpp b/jsk2350/P1.cpp new file mode 100644 index 0000000..cfa72d3 --- /dev/null +++ b/jsk2350/P1.cpp @@ -0,0 +1,54 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +ll calc2(ll id) +{ + //return log2l(id + 1) + 1; + int ret = 0; + while ((1ll << ret) < id + 2) ret++; + return ret; +} +bool isPrefix(ll a, ll b) +{ + if (a == 0) return true; + for (; b; b >>= 1) + if (a == b) return true; + return false; +} +int main() +{ + ll m, k, q, op, x; + scanf("%lld%lld%lld", &m, &k, &q); + set rm; + if (m == 1) + while (q--) + { + scanf("%lld%lld", &op, &x); + if (op == 1) + rm.insert(x); + if (op == 2) + rm.erase(x); + printf("%lld\n", rm.empty() ? k : *rm.begin()); + } + if (m == 2) + while (q--) + { + scanf("%lld%lld", &op, &x); + if (op == 1) + rm.insert(x); + if (op == 2) + rm.erase(x); + ll cnt = (1ll << k) - 1; + for (auto ite = rm.begin(); ite != rm.end(); ++ite) + { + bool flag = true; + for (auto ite2 = rm.begin(); ite2 != ite && flag; ++ite2) + flag = !isPrefix(*ite2 + 1, *ite + 1); + if (flag) cnt -= (1ll << (k - calc2(*ite) + 1)) - 1; + } + printf("%lld\n", cnt); + } + return 0; +} diff --git a/jsk2350/P2.cpp b/jsk2350/P2.cpp new file mode 100644 index 0000000..4ac4f72 --- /dev/null +++ b/jsk2350/P2.cpp @@ -0,0 +1,27 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 105; +const ll mod = 1e9 + 7; +ll a[N]; +ll f(ll l, ll r) +{ + ll max1 = numeric_limits::min(); + for (ll x = l; x <= r; x++) + max1 = max(max1, (r - x + 1) * *max_element(a + l, a + x + 1)); + return max1; +} +int main() +{ + int n; + scanf("%d", &n); + for (int i = 0; i < n; i++) scanf("%lld", a + i); + ll ans = 0; + for (int i = 0; i < n; i++) + for (int j = i; j < n; j++) + ans = (ans + f(i, j)) % mod; + printf("%lld", ans); + return 0; +} diff --git a/jsk2350/P3.cpp b/jsk2350/P3.cpp new file mode 100644 index 0000000..97a933a --- /dev/null +++ b/jsk2350/P3.cpp @@ -0,0 +1,21 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 2e5 + 50; +const ll mod = 1e9 + 7; +ll a[N]; +int main() +{ + int n; + scanf("%d", &n); + for (int i = 0; i < n; i++) scanf("%lld", a + i); + ll ans = 0; + unordered_multiset S{a, a + n}; + for (int i = 0; i < n; i++) + { + } + printf("%lld", ans); + return 0; +} diff --git a/jsk2350/P4.cpp b/jsk2350/P4.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2350/P4.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2351/CMakeLists.txt b/jsk2351/CMakeLists.txt new file mode 100644 index 0000000..c190f81 --- /dev/null +++ b/jsk2351/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(P1 P1.cpp) +add_executable(P2 P2.cpp) +add_executable(P3 P3.cpp) +add_executable(P4 P4.cpp) \ No newline at end of file diff --git a/jsk2351/P1.cpp b/jsk2351/P1.cpp new file mode 100644 index 0000000..89b933c --- /dev/null +++ b/jsk2351/P1.cpp @@ -0,0 +1,21 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1e6 + 60; +char s[N]; +int main() +{ + scanf("%s", s); + int n = strlen(s); + for (int i = 0, j = n; i < j;) + if (s[i++] == s[--j]) return puts("NO"), 0; + stack st; + for (int i = 0; i < n; i++) + if (!st.empty() && st.top() == '(' && s[i] == ')') + st.pop(); + else + st.push(s[i]); + puts(st.empty() ? "YES" : "NO"); + return 0; +} diff --git a/jsk2351/P2.cpp b/jsk2351/P2.cpp new file mode 100644 index 0000000..17f75eb --- /dev/null +++ b/jsk2351/P2.cpp @@ -0,0 +1,34 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 105; +int a[N], b[N]; +ll f(int i, int x) +{ + return 1ll * (x - a[i]) * (x - a[i]) + b[i]; +} +ll g(int x, int n) +{ + ll mx; + memset(&mx, 0x3f, sizeof(mx)); + for (int i = 1; i <= n; i++) + mx = min(mx, f(i, x)); + return mx; +} +int main() +{ + int n, q; + scanf("%d", &n); + for (int i = 1; i <= n; i++) scanf("%d", a + i); + for (int i = 1; i <= n; i++) scanf("%d", b + i); + scanf("%d", &q); + while (q--) + { + int x; + scanf("%d", &x); + printf("%lld ", g(x, n)); + } + return 0; +} diff --git a/jsk2351/P3.cpp b/jsk2351/P3.cpp new file mode 100644 index 0000000..1ee7510 --- /dev/null +++ b/jsk2351/P3.cpp @@ -0,0 +1,34 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 5050; +int a[N], b[N]; +ll f(int i, int x) +{ + return 1ll * (x - a[i]) * (x - a[i]) + b[i]; +} +ll g(int x, int n) +{ + ll mx; + memset(&mx, 0x3f, sizeof(mx)); + for (int i = 1; i <= n; i++) + mx = min(mx, f(i, x)); + return mx; +} +int main() +{ + int n, q; + scanf("%d", &n); + for (int i = 1; i <= n; i++) scanf("%d", a + i); + for (int i = 1; i <= n; i++) scanf("%d", b + i); + scanf("%d", &q); + while (q--) + { + int x; + scanf("%d", &x); + printf("%lld ", g(x, n)); + } + return 0; +} diff --git a/jsk2351/P4.cpp b/jsk2351/P4.cpp new file mode 100644 index 0000000..335e656 --- /dev/null +++ b/jsk2351/P4.cpp @@ -0,0 +1,32 @@ +#pragma GCC optimize("O3") +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 1e6 + 50; +int a[N], b[N]; +int main() +{ + int n, q; + scanf("%d", &n); + for (int i = 1; i <= n; i++) scanf("%d", a + i); + for (int i = 1; i <= n; i++) scanf("%d", b + i); + auto mm = minmax_element(b + 1, b + n + 1); + int rg = sqrt(*mm.second - *mm.first) / 4, po = 1; + scanf("%d", &q); + ll inf; + memset(&inf, 0x3f, sizeof(inf)); + while (q--) + { + int x; + scanf("%d", &x); + ll mx = inf; + while (a[po] < x && po <= n) po++; + int st = max(1, po - rg), ed = min(n, po + rg); + for (int i = st; i <= ed; i++) + mx = min(mx, 1ll * (x - a[i]) * (x - a[i]) + b[i]); + printf("%lld ", mx); + } + return 0; +} diff --git a/jsk2421/CMakeLists.txt b/jsk2421/CMakeLists.txt new file mode 100644 index 0000000..997e2ff --- /dev/null +++ b/jsk2421/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") +add_executable(P01 P01.cpp) +add_executable(P02 P02.cpp) +add_executable(P03 P03.cpp) +add_executable(P04 P04.cpp) +add_executable(P05 P05.cpp) +add_executable(P06 P06.cpp) +add_executable(P07 P07.cpp) +add_executable(P08 P08.cpp) +add_executable(P09 P09.cpp) +add_executable(P10 P10.cpp) +add_executable(P11 P11.cpp) +add_executable(P12 P12.cpp) +add_executable(P13 P13.cpp) \ No newline at end of file diff --git a/jsk2421/P01.cpp b/jsk2421/P01.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P01.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P02.cpp b/jsk2421/P02.cpp new file mode 100644 index 0000000..e0065c0 --- /dev/null +++ b/jsk2421/P02.cpp @@ -0,0 +1,25 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 50005; +const int mod = 192600817; +ll f[N]; +int main() +{ + f[1] = f[2] = 1; + for (int i = 3; i < N; i++) f[i] = (f[i - 1] + f[i - 2]) % mod; + for (int i = 1; i < N; i++) f[i] = f[i] * f[i] % mod; + for (int i = 1; i < N; i++) f[i] = (f[i] + f[i - 1]) % mod; + for (int Q, a, b, c, d; ~scanf("%d", &Q);) + while (Q--) + { + scanf("%d%d%d%d", &a, &b, &c, &d); + b += a << 2; + d += c << 2; + if (b > d) swap(b, d); + printf("%lld\n", (f[d+1] - f[b] + mod) % mod); + } + return 0; +} diff --git a/jsk2421/P03.cpp b/jsk2421/P03.cpp new file mode 100644 index 0000000..224f884 --- /dev/null +++ b/jsk2421/P03.cpp @@ -0,0 +1,34 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 15e4 + 40; +int lst[N]; +int vis[1044650]; +int str[256]; +bool isPigeon(int x, int c) +{ + while (x > 1) + { + if (vis[x] == c) return false; + vis[x] = c; + int len = 0; + for (; x; x /= 10) + str[len++] = x % 10; + for (int i = 0; i < len; i++) + x += str[i] * str[i]; + } + return true; +} +int main() +{ + int rs = 0; + for (int i = 1; rs < N; i++) + if (isPigeon(i, i)) + lst[rs++] = i; + int Q, k; + scanf("%d", &Q); + while (Q--) + scanf("%d", &k), printf("%d\n", lst[k - 1]); + return 0; +} diff --git a/jsk2421/P04.cpp b/jsk2421/P04.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P04.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P05.cpp b/jsk2421/P05.cpp new file mode 100644 index 0000000..9bdf86b --- /dev/null +++ b/jsk2421/P05.cpp @@ -0,0 +1,86 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int MAXN = 6; +const double EPS = 1e-8; +double a[10][10]; +int solve(bool l[], double ans[], const int &n) +{ + int res = 0, r = 0; + for (int i = 0; i < n; ++i) l[i] = false; + for (int i = 0; i < n; ++i) + { + for (int j = r; j < n; ++j) + if (fabs(a[j][i]) > EPS) + { + for (int k = i; k <= n; ++k) swap(a[j][k], a[r][k]); + break; + } + if (fabs(a[r][i]) < EPS) + { + ++res; + continue; + } + for (int j = 0; j < n; ++j) + if (j != r && fabs(a[j][i]) > EPS) + { + double tmp = a[j][i] / a[r][i]; + for (int k = i; k <= n; ++k) a[j][k] -= tmp * a[r][k]; + } + l[i] = true, ++r; + } + for (int i = 0; i < n; ++i) + if (l[i]) + for (int j = 0; j < n; ++j) + if (fabs(a[j][i]) > 0) ans[i] = a[j][n] / a[j][i]; + return res; +} +int main() +{ + int T, Q; + scanf("%d", &T); + while (T--) + { + int x1, y1, x2, y2, x3, y3; + int x4, y4, x5, y5, x6, y6; + scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3); + scanf("%d%d%d%d%d%d", &x4, &y4, &x5, &y5, &x6, &y6); + bool l[MAXN]; + double ans[MAXN]; + memset(l, 0, sizeof l); + memset(ans, 0, sizeof ans); + memset(a, 0, sizeof a); + a[0][0] = x1; + a[0][2] = y1; + a[0][6] = x4; + a[1][1] = x1; + a[1][3] = y1; + a[1][6] = y4; + + a[2][0] = x2; + a[2][2] = y2; + a[2][6] = x5; + a[3][1] = x2; + a[3][3] = y2; + a[3][6] = y5; + + a[4][0] = x3; + a[4][2] = y3; + a[4][6] = x6; + a[5][1] = x3; + a[5][3] = y3; + a[5][6] = y6; + solve(l, ans, MAXN); + for (int i = 0; i < MAXN; i++) + printf("%c %d %.4lf\n", 'a' + i, l[i], ans[i]); + scanf("%d", &Q); + while (Q--) + { + int x, y; + scanf("%d%d", &x, &y); + printf("%.2lf %.2lf\n", ans[0] * x + ans[2] * y, ans[1] * x + ans[3] * y); + } + } + return 0; +} diff --git a/jsk2421/P06.cpp b/jsk2421/P06.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P06.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P07.cpp b/jsk2421/P07.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P07.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P08.cpp b/jsk2421/P08.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P08.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P09.cpp b/jsk2421/P09.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P09.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P10.cpp b/jsk2421/P10.cpp new file mode 100644 index 0000000..4a3f984 --- /dev/null +++ b/jsk2421/P10.cpp @@ -0,0 +1,59 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long mat[6][6]; +const int mod = 123456789; +const size_t sz = sizeof(long long) * 36; +void mul(mat a, mat b) +{ + mat c; + memset(c, 0, sz); + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + for (int k = 0; k < 6; k++) + c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % mod; + memcpy(a, c, sz); +} +void fpow(mat ret, mat a, long long b) +{ + memset(ret, 0, sz); + for (int i = 0; i < 6; i++) ret[i][i] = 1; + for (; b; b >>= 1, mul(a, a)) + if (b & 1) + mul(ret, a); +} +int main() +{ + int T; + long long n; + scanf("%d", &T); + while (T--) + { + scanf("%lld", &n); + if (n <= 2) + printf("%lld\n", n); + else + { + mat b = { + {1, 0, 0, 0, 0, 0}, + {2, 0, 0, 0, 0, 0}, + {8, 0, 0, 0, 0, 0}, + {4, 0, 0, 0, 0, 0}, + {2, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0}}; + mat a = { + {0, 1, 0, 0, 0, 0}, + {2, 1, 1, 3, 3, 1}, + {0, 0, 1, 3, 3, 1}, + {0, 0, 0, 1, 2, 1}, + {0, 0, 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 1}}; + mat ret; + fpow(ret, a, n - 2); + mul(ret, b); + printf("%lld\n", ret[1][0]); + } + } + return 0; +} diff --git a/jsk2421/P11.cpp b/jsk2421/P11.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P11.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P12.cpp b/jsk2421/P12.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P12.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2421/P13.cpp b/jsk2421/P13.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2421/P13.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2983/1.py b/jsk2983/1.py new file mode 100644 index 0000000..e69de29 diff --git a/jsk2983/2.py b/jsk2983/2.py new file mode 100644 index 0000000..99dac41 --- /dev/null +++ b/jsk2983/2.py @@ -0,0 +1,19 @@ +def atoi(x): + if x == '': + return 0 + else: + return int(x) + + +_ = int(input()) +s = input() +n = len(s) +l = r = n // 2 +while l >= 0 and s[l] == '0': + l -= 1 +while r < n and s[r] == '0': + r += 1 +if l == r: + print(min(atoi(s[:sp]) + atoi(s[sp:]) for sp in [n // 2, (n + 1) // 2])) +else: + print(min(atoi(s[:sp]) + atoi(s[sp:]) for sp in [l, r])) diff --git a/jsk2983/CMakeLists.txt b/jsk2983/CMakeLists.txt new file mode 100644 index 0000000..6ba3a4c --- /dev/null +++ b/jsk2983/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(P01 P01.cpp) +add_executable(P02 P02.cpp) +add_executable(P03 P03.cpp) +add_executable(P04 P04.cpp) +add_executable(P05 P05.cpp) +add_executable(P06 P06.cpp) +add_executable(P07 P07.cpp) \ No newline at end of file diff --git a/jsk2983/P01.cpp b/jsk2983/P01.cpp new file mode 100644 index 0000000..aa67aea --- /dev/null +++ b/jsk2983/P01.cpp @@ -0,0 +1,14 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + long long x, y, z; + cin >> x >> y >> z; + if (x + y < z) + cout << "0 0"; + else + cout << (x + y) / z<<" " << max(min(((x + y) / z - x / z) * z - y, ((x + y) / z - y / z) * z - x), 0ll); + return 0; +} diff --git a/jsk2983/P02.cpp b/jsk2983/P02.cpp new file mode 100644 index 0000000..e0065c0 --- /dev/null +++ b/jsk2983/P02.cpp @@ -0,0 +1,25 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +typedef long long ll; +const int N = 50005; +const int mod = 192600817; +ll f[N]; +int main() +{ + f[1] = f[2] = 1; + for (int i = 3; i < N; i++) f[i] = (f[i - 1] + f[i - 2]) % mod; + for (int i = 1; i < N; i++) f[i] = f[i] * f[i] % mod; + for (int i = 1; i < N; i++) f[i] = (f[i] + f[i - 1]) % mod; + for (int Q, a, b, c, d; ~scanf("%d", &Q);) + while (Q--) + { + scanf("%d%d%d%d", &a, &b, &c, &d); + b += a << 2; + d += c << 2; + if (b > d) swap(b, d); + printf("%lld\n", (f[d+1] - f[b] + mod) % mod); + } + return 0; +} diff --git a/jsk2983/P03.cpp b/jsk2983/P03.cpp new file mode 100644 index 0000000..0091211 --- /dev/null +++ b/jsk2983/P03.cpp @@ -0,0 +1,36 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1050; +char a[N][N]; +int main() +{ + int n, m; + scanf("%d%d", &n, &m); + for (int i = 0; i < n; i++) + scanf("%s", a + i); + for (int i = 0; i < N; i++) + for (int j = 0; j < i; j++) + swap(a[i][j], a[j][i]); + long long ans = 0; + for (int i = 0; i < n; i++) + for (int l = 1; l <= (n - i) / 3; l++) + for (int j = 0; j < m; j++) + { + bool flag = a[j][i] != a[j][i + l] && a[j][i + l] != a[j][i + l + l]; + for (int t = 0; t < 3; t++) + for (int k = 0; k < l && flag; k++) + if (a[j][i + l * t] != a[j][i + l * t + k]) + flag = false; + int rmost = j; + while (flag && memcmp(a[j] + i, a[rmost] + i, l * 3) == 0) rmost++; + if (rmost != j) + { + ans += (rmost - j) * (rmost - j + 1) / 2; + j = rmost - 1; + } + } + cout << ans; + return 0; +} \ No newline at end of file diff --git a/jsk2983/P04.cpp b/jsk2983/P04.cpp new file mode 100644 index 0000000..0df4e50 --- /dev/null +++ b/jsk2983/P04.cpp @@ -0,0 +1,30 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 5000050; +char s[N]; +deque pos[26]; +int main() +{ + const auto sz = acos(-1); + int k; + scanf("%s%d", s, &k); + int n = strlen(s); + for (int i = 0; i < n; i++) pos[s[i] - 'a'].push_back(i); + int lmost = 0, lsec = 0; + while (pos[lmost].empty()) lmost++; + lsec = lmost + 1; + while (lsec < 26 && pos[lsec].empty()) lsec++; + for (int i = 0; i < n; i++) + { + while (pos[lmost].size() && pos[lmost].front() < i) pos[lmost].pop_front(); + if (pos[lmost].empty()) + { + while (pos[lmost].empty()) lmost++; + lsec = lmost + 1; + while (lsec < 26 && pos[lsec].empty()) lsec++; + } + } + return 0; +} diff --git a/jsk2983/P05.cpp b/jsk2983/P05.cpp new file mode 100644 index 0000000..3039fa6 --- /dev/null +++ b/jsk2983/P05.cpp @@ -0,0 +1,38 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1000050; +char s[N], s2[N]; +char st[N]; +int top; +bool check(int l) +{ + top = 0; + for (int i = 0; i < l; i++) + if (top && st[top - 1] == '(' && s[i] == ')') + top--; + else + st[top++] = s[i]; + return top == 0; +} +int main() +{ + scanf("%s", s2); + int n = strlen(s2); + memcpy(s, s2, n); + while (prev_permutation(s, s + n)) + if (check(n)) + { + puts(s); + break; + } + memcpy(s, s2, n); + while (next_permutation(s, s + n)) + if (check(n)) + { + puts(s); + break; + } + return 0; +} diff --git a/jsk2983/P06.cpp b/jsk2983/P06.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2983/P06.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/jsk2983/P07.cpp b/jsk2983/P07.cpp new file mode 100644 index 0000000..6823825 --- /dev/null +++ b/jsk2983/P07.cpp @@ -0,0 +1,8 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +int main() +{ + return 0; +} diff --git a/lanqiao/PREV/CMakeLists.txt b/lanqiao/PREV/CMakeLists.txt index ee6e92e..53cc15e 100644 --- a/lanqiao/PREV/CMakeLists.txt +++ b/lanqiao/PREV/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_CXX_STANDARD 17) if (MSVC) add_compile_options("/Zc:__cplusplus" "/wd6031") - include_directories("C:\\Programs\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") + include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32") endif () add_executable("PREV-01" "PREV-01.cpp") add_executable("PREV-02" "PREV-02.cpp") diff --git a/lanqiao/PREV/PREV-09.cpp b/lanqiao/PREV/PREV-09.cpp index 6823825..8f05dc5 100644 --- a/lanqiao/PREV/PREV-09.cpp +++ b/lanqiao/PREV/PREV-09.cpp @@ -2,7 +2,33 @@ #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; +const int N = 1e4 + 50; +int adj[N], nxt[N], to[N], len[N], ecnt; +int dis[N]; +inline void addEdge(int f, int t, int l) +{ + ecnt++; + nxt[ecnt] = adj[f]; + adj[f] = ecnt; + to[ecnt] = t; + len[ecnt] = l; +} +void dijkstra(int S) +{ + static int que[N]; + int l = 0; + for (dis[que[l++] = S] = 0; l; pop_heap(que, que + l--)) + { + } +} int main() { + int n; + scanf("%d", &n); + for (int i = 1, p, q, d; i < n; i++) + scanf("%d%d%d", &p, &q, &d), addEdge(p, q, d), addEdge(q, p, d); + for (int i = 1; i <= n; i++) + { + } return 0; }