diff --git a/.vscode/settings.json b/.vscode/settings.json index be18cf8..7b00b3d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -39,5 +39,6 @@ "sstream": "cpp", "stdexcept": "cpp", "streambuf": "cpp" - } + }, + "python.formatting.provider": "yapf" } \ No newline at end of file diff --git a/.wakatime-project b/.wakatime-project deleted file mode 100644 index 5fd3436..0000000 --- a/.wakatime-project +++ /dev/null @@ -1 +0,0 @@ -Noisy Shadow 59 \ No newline at end of file diff --git a/1224/CMakeLists.txt b/20181224/CMakeLists.txt similarity index 95% rename from 1224/CMakeLists.txt rename to 20181224/CMakeLists.txt index 17e13f8..7511e15 100644 --- a/1224/CMakeLists.txt +++ b/20181224/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.0) -set(CMAKE_CXX_STANDARD 17) -if(MSVC) - add_compile_options("/Zc:__cplusplus") -endif() -include_directories("C:\\Programs\\GCC\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32") -add_executable(P01 P01.cpp) -add_executable(P02 P02.cpp) -add_executable(P03 P03.cpp) -add_executable(P04 P04.cpp) +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("C:\\Programs\\GCC\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\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) \ No newline at end of file diff --git a/1224/P01.cpp b/20181224/P01.cpp similarity index 96% rename from 1224/P01.cpp rename to 20181224/P01.cpp index e1bad49..3799878 100644 --- a/1224/P01.cpp +++ b/20181224/P01.cpp @@ -1,21 +1,21 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -#include -using namespace std; -const int N = 1e5 + 50; -int l[N], r[N]; -int main() -{ - int n; - scanf("%d", &n); - for (int i = 1; i <= n; i++) - scanf("%d%d", l + i, r + i); - int L = *min_element(l + 1, l + n + 1); - int R = *max_element(r + 1, r + n + 1); - int ans = -1; - for (int i = 1; i <= n; i++) - if (l[i] == L && r[i] == R) - ans = i; - printf("%d", ans); - return 0; -} +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1e5 + 50; +int l[N], r[N]; +int main() +{ + int n; + scanf("%d", &n); + for (int i = 1; i <= n; i++) + scanf("%d%d", l + i, r + i); + int L = *min_element(l + 1, l + n + 1); + int R = *max_element(r + 1, r + n + 1); + int ans = -1; + for (int i = 1; i <= n; i++) + if (l[i] == L && r[i] == R) + ans = i; + printf("%d", ans); + return 0; +} diff --git a/1224/P02.cpp b/20181224/P02.cpp similarity index 96% rename from 1224/P02.cpp rename to 20181224/P02.cpp index 3929cf1..4333afe 100644 --- a/1224/P02.cpp +++ b/20181224/P02.cpp @@ -1,22 +1,22 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -#include -using namespace std; -const int N = 55; -int a1[N], a2[N], b[N], d[N]; -int main() -{ - int n; - scanf("%d", &n); - for (int i = 1; i < n; i++) - scanf("%d", a1 + i), a1[i] += a1[i - 1]; - for (int i = 1; i < n; i++) - scanf("%d", a2 + i), a2[i] += a2[i - 1]; - for (int i = 0; i < n; i++) - scanf("%d", b + i); - for (int i = 0; i < n; i++) - d[i] = a1[i] + b[i] + (a2[n - 1] - a2[i]); - sort(d, d + n); - printf("%d", d[0] + d[1]); - return 0; -} +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 55; +int a1[N], a2[N], b[N], d[N]; +int main() +{ + int n; + scanf("%d", &n); + for (int i = 1; i < n; i++) + scanf("%d", a1 + i), a1[i] += a1[i - 1]; + for (int i = 1; i < n; i++) + scanf("%d", a2 + i), a2[i] += a2[i - 1]; + for (int i = 0; i < n; i++) + scanf("%d", b + i); + for (int i = 0; i < n; i++) + d[i] = a1[i] + b[i] + (a2[n - 1] - a2[i]); + sort(d, d + n); + printf("%d", d[0] + d[1]); + return 0; +} diff --git a/1224/P03.cpp b/20181224/P03.cpp similarity index 96% rename from 1224/P03.cpp rename to 20181224/P03.cpp index 1257ba3..4ca7145 100644 --- a/1224/P03.cpp +++ b/20181224/P03.cpp @@ -1,30 +1,30 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -#include -using namespace std; -const int N = 1 << 20; -char buf[N]; -int diff[N]; -int calc(char a, char b) -{ - if (a > b) swap(a, b); - return min(b - a, a + 26 - b); -} -int main() -{ - int n, p; - scanf("%d%d%s", &n, &p, buf); - p--; - if (p >= (n >> 1)) p = n - p - 1, reverse(buf, buf + n); - for (int i = 0; i < (n >> 1); i++) diff[i] = calc(buf[i], buf[n - i - 1]); - int L = p, R = p; - for (int i = p; i >= 0; i--) - if (diff[i]) L = i; - for (int i = p; i < (n >> 1); i++) - if (diff[i]) R = i; - int base_ans = accumulate(diff + L, diff + R + 1, 0); - if (L == p) return printf("%d", base_ans + R - p), 0; - if (R == p) return printf("%d", base_ans + p - L), 0; - printf("%d", base_ans + R - L + min(R - p, p - L)); - return 0; -} +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1 << 20; +char buf[N]; +int diff[N]; +int calc(char a, char b) +{ + if (a > b) swap(a, b); + return min(b - a, a + 26 - b); +} +int main() +{ + int n, p; + scanf("%d%d%s", &n, &p, buf); + p--; + if (p >= (n >> 1)) p = n - p - 1, reverse(buf, buf + n); + for (int i = 0; i < (n >> 1); i++) diff[i] = calc(buf[i], buf[n - i - 1]); + int L = p, R = p; + for (int i = p; i >= 0; i--) + if (diff[i]) L = i; + for (int i = p; i < (n >> 1); i++) + if (diff[i]) R = i; + int base_ans = accumulate(diff + L, diff + R + 1, 0); + if (L == p) return printf("%d", base_ans + R - p), 0; + if (R == p) return printf("%d", base_ans + p - L), 0; + printf("%d", base_ans + R - L + min(R - p, p - L)); + return 0; +} diff --git a/1224/P04.cpp b/20181224/P04.cpp similarity index 96% rename from 1224/P04.cpp rename to 20181224/P04.cpp index 39078c9..af90ea9 100644 --- a/1224/P04.cpp +++ b/20181224/P04.cpp @@ -1,21 +1,21 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -#include -using namespace std; -const int N = 1 << 20; -char buf[N]; -int main() -{ - scanf("%s", buf); - int len = strlen(buf); - bool flag = false; - putchar(buf[0]); - for (int i = 1; i < len;) - if (memcmp(buf + i, "dot", 3) == 0 && i + 3 < len) - putchar('.'), i += 3; - else if (!flag && memcmp(buf + i, "at", 2) == 0 && i + 2 < len) - putchar('@'), i += 2, flag = true; - else - putchar(buf[i]), i++; - return 0; -} +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1 << 20; +char buf[N]; +int main() +{ + scanf("%s", buf); + int len = strlen(buf); + bool flag = false; + putchar(buf[0]); + for (int i = 1; i < len;) + if (memcmp(buf + i, "dot", 3) == 0 && i + 3 < len) + putchar('.'), i += 3; + else if (!flag && memcmp(buf + i, "at", 2) == 0 && i + 2 < len) + putchar('@'), i += 2, flag = true; + else + putchar(buf[i]), i++; + return 0; +} diff --git a/1224/P05.cpp b/20181224/P05.cpp similarity index 95% rename from 1224/P05.cpp rename to 20181224/P05.cpp index 4b3d7e6..a1d2e49 100644 --- a/1224/P05.cpp +++ b/20181224/P05.cpp @@ -1,29 +1,29 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -#include -using namespace std; -const int N = 1 << 10; -int w[N], b[N]; -int p[N]; -bool u[N]; -int main() -{ - int n, m; - scanf("%d%d", &n, &m); - for (int i = 1; i <= n; i++) - scanf("%d", w + i); - for (int i = 1; i <= m; i++) - scanf("%d", b + i); - memset(p, 0, sizeof(p)); - long long ans = 0; - for (int i = 1; i <= m; i++) - { - memset(u, 0, sizeof(u)); - for (int j = p[b[i]] + 1; j < i; j++) - if (!u[b[j]]) - ans += w[b[j]], u[b[j]] = true; - p[b[i]] = i; - } - printf("%lld", ans); - return 0; -} +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +const int N = 1 << 10; +int w[N], b[N]; +int p[N]; +bool u[N]; +int main() +{ + int n, m; + scanf("%d%d", &n, &m); + for (int i = 1; i <= n; i++) + scanf("%d", w + i); + for (int i = 1; i <= m; i++) + scanf("%d", b + i); + memset(p, 0, sizeof(p)); + long long ans = 0; + for (int i = 1; i <= m; i++) + { + memset(u, 0, sizeof(u)); + for (int j = p[b[i]] + 1; j < i; j++) + if (!u[b[j]]) + ans += w[b[j]], u[b[j]] = true; + p[b[i]] = i; + } + printf("%lld", ans); + return 0; +} diff --git a/TmplPatch_2019Nanjing/proof_of_inv_table.md b/TmplPatch_2019Nanjing/proof_of_inv_table.md deleted file mode 100644 index 2613716..0000000 --- a/TmplPatch_2019Nanjing/proof_of_inv_table.md +++ /dev/null @@ -1,15 +0,0 @@ -```cpp -invT[1] = 1; -for (int i = 2; i < N; i++) - invT[i] = (mod - mod / i) * invT[mod % i] % mod; -``` - -$$ -p=ax+b \\ -ax+b \equiv 0 \pmod p\\ -ab^{-1}+x^{-1} \equiv 0 \pmod p \\ -x^{-1} \equiv -ab^{-1} \pmod p \\ -x^{-1} \equiv -\left \lfloor \frac{p}{x} \right \rfloor (p\bmod x)^{-1} \pmod p \\ -x^{-1} \equiv (p-p/x) (p\bmod x)^{-1} \pmod p \\ -$$ - diff --git a/cf1331/A.cpp b/cf1331/A.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1331/A.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1417/A.cpp b/cf1417/A.cpp new file mode 100644 index 0000000..7a71282 --- /dev/null +++ b/cf1417/A.cpp @@ -0,0 +1,90 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + int T, n, k, x; + read(T); + while (T--) + { + read(n, k); + priority_queue, greater> Q; + for (int i = 0; i < n; i++) read(x), Q.push(x); + int cnt = 0; + while (Q.size() > 1) + { + int m1 = Q.top(); + Q.pop(); + int m2 = Q.top(); + Q.pop(); + if (m1 + m2 > k) break; + Q.push(m1 + m2); + Q.push(m1); + cnt++; + } + printf("%d\n", cnt); + } + return 0; +} \ No newline at end of file diff --git a/cf1417/B.cpp b/cf1417/B.cpp new file mode 100644 index 0000000..9b484e0 --- /dev/null +++ b/cf1417/B.cpp @@ -0,0 +1,87 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 1e5 + 50; +int a[N]; +int main() +{ + int T, n, k; + read(T); + while (T--) + { + read(n, k); + for (int i = 0; i < n; i++) read(a[i]); + int ans = 0; + int f = 0; + for (int i = 0; i < n; i++) + { + if (a[i] * 2 < k) printf("1 "); + if (a[i] * 2 > k) printf("0 "); + if (a[i] * 2 == k) printf("%d ", f ^= 1); + } + puts(""); + } + return 0; +} \ No newline at end of file diff --git a/cf1417/C.cpp b/cf1417/C.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1417/C.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1417/CMakeLists.txt b/cf1417/CMakeLists.txt new file mode 100644 index 0000000..c9eb24d --- /dev/null +++ b/cf1417/CMakeLists.txt @@ -0,0 +1,11 @@ +project(cf1417) +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++\\10.2.0\\x86_64-w64-mingw32") +add_executable(A A.cpp) +add_executable(B B.cpp) +add_executable(C C.cpp) +add_executable(D D.cpp) \ No newline at end of file diff --git a/cf1417/D.cpp b/cf1417/D.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1417/D.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/A.cpp b/cf1425/A.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/A.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/B.cpp b/cf1425/B.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/B.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/C.cpp b/cf1425/C.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/C.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/CMakeLists.txt b/cf1425/CMakeLists.txt new file mode 100644 index 0000000..ad9af7f --- /dev/null +++ b/cf1425/CMakeLists.txt @@ -0,0 +1,16 @@ +project(cf1425) +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++\\10.2.0\\x86_64-w64-mingw32") +add_executable(A A.cpp) +add_executable(B B.cpp) +add_executable(C C.cpp) +add_executable(D D.cpp) +add_executable(E E.cpp) +add_executable(F F.cpp) +add_executable(G G.cpp) +add_executable(H H.cpp) +add_executable(I I.cpp) \ No newline at end of file diff --git a/cf1425/D.cpp b/cf1425/D.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/D.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/E.cpp b/cf1425/E.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/E.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/F.cpp b/cf1425/F.cpp new file mode 100644 index 0000000..c3069a4 --- /dev/null +++ b/cf1425/F.cpp @@ -0,0 +1,93 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 1e3 + 50; +int ans[N]; +int fans[N]; +int main() +{ + int n; + scanf("%d", &n); + for (int i = 1; i < n; i++) + { + printf("? %d %d\n", i, n); + fflush(stdout); + scanf("%d", ans + i); + } + for (int i = 0; i < n - 2; i++) + fans[i] = ans[i + 1] - ans[i + 2]; + printf("? %d %d\n", 1, n - 1); + fflush(stdout); + int x; + scanf("%d", &x); + int sum1 = accumulate(fans, fans + n - 2, 0); + fans[n - 2] = x - sum1; + fans[n - 1] = ans[1] - sum1 - fans[n - 2]; + printf("!"); + for (int i = 0; i < n; i++) printf(" %d", fans[i]); + puts(""); + fflush(stdout); + return 0; +} \ No newline at end of file diff --git a/cf1425/G.cpp b/cf1425/G.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/G.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1425/H.cpp b/cf1425/H.cpp new file mode 100644 index 0000000..14a9092 --- /dev/null +++ b/cf1425/H.cpp @@ -0,0 +1,81 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +char *ans[] = {"Tidak", "Ya"}; +int main() +{ + int T, a, b, c, d; + read(T); + while (T--) + { + read(a, b, c, d); + c += b, d += a; + if ((a + b) & 1) //neg + printf("%s %s Tidak Tidak\n", ans[!!d], ans[!!c]); + else //pos + printf("Tidak Tidak %s %s\n", ans[!!c], ans[!!d]); + } + return 0; +} \ No newline at end of file diff --git a/cf1425/I.cpp b/cf1425/I.cpp new file mode 100644 index 0000000..87c19fb --- /dev/null +++ b/cf1425/I.cpp @@ -0,0 +1,70 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + + return 0; +} \ No newline at end of file diff --git a/cf1608/A.cpp b/cf1608/A.cpp new file mode 100644 index 0000000..ec46d3f --- /dev/null +++ b/cf1608/A.cpp @@ -0,0 +1,94 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 105; +int a[N], b[N], c[N]; +int main() +{ + int T, n; + read(T); + while (T--) + { + read(n); + for (int i = 0; i < n; i++) read(a[i]); + for (int i = 0; i < n; i++) read(b[i]); + for (int i = 0; i < n; i++) read(c[i]); + int last = -1; + for (int i = 0; i < n - 1; i++) + { + if (a[i] == last) + printf("%d ", last = b[i]); + else + printf("%d ", last = a[i]); + } + if (a[n - 1] != last && a[n - 1] != a[0]) + printf("%d\n", a[n - 1]); + else if (b[n - 1] != last && b[n - 1] != a[0]) + printf("%d\n", b[n - 1]); + else + printf("%d\n", c[n - 1]); + } + return 0; +} \ No newline at end of file diff --git a/cf1608/B.cpp b/cf1608/B.cpp new file mode 100644 index 0000000..14e893b --- /dev/null +++ b/cf1608/B.cpp @@ -0,0 +1,85 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int a[105]; +int main() +{ + int T, n, k; + read(T); + while (T--) + { + read(n, k); + for (int i = 0; i < n; i++) read(a[i]); + sort(a, a + n); + int l = unique(a, a + n) - a; + if (l != 1 && k == 1) + puts("-1"); + else if (l == 1) + puts("1"); + else + printf("%d\n", (l - 1 + k - 2) / (k - 1)); + } + return 0; +} \ No newline at end of file diff --git a/cf1608/C.cpp b/cf1608/C.cpp new file mode 100644 index 0000000..feb1af2 --- /dev/null +++ b/cf1608/C.cpp @@ -0,0 +1,112 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 1e5 + 50; +double ta[N], tb[N]; +int p[N]; +int main() +{ + int T, n, len; + read(T); + while (T--) + { + read(n, len); + for (int i = 1; i <= n; i++) read(p[i]); + p[n + 1] = len; + tb[n + 1] = 0; + for (int i = 1, curspeed = 1; i <= n + 1; i++) + { + ta[i] = ta[i - 1] + 1.0 * (p[i] - p[i - 1]) / curspeed; + curspeed++; + } + for (int i = n, curspeed = 1; i >= 0; i--) + { + tb[i] = tb[i + 1] + 1.0 * (p[i + 1] - p[i]) / curspeed; + curspeed++; + } + for (int i = 0; i <= n + 1; i++) + if (ta[i] > tb[i]) + { + i--; + double ans = 0; + double dis = p[i + 1] - p[i]; + if (ta[i] > tb[i + 1]) + { + ans += ta[i]; + dis -= abs(ta[i] - tb[i + 1]) * (n - i + 1); + ans += dis / (n + 2); + } + else + { + ans += tb[i + 1]; + dis -= abs(ta[i] - tb[i + 1]) * (i + 1); + ans += dis / (n + 2); + } + printf("%.15lf\n", ans); + break; + } + } + return 0; +} \ No newline at end of file diff --git a/hdu/6889.cpp b/hdu/6889.cpp new file mode 100644 index 0000000..bba11be --- /dev/null +++ b/hdu/6889.cpp @@ -0,0 +1,128 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +namespace Min25 +{ +const int N = 1000010; +int prime[N], id1[N], id2[N], flag[N], ncnt, m; +ll g[N], sum[N], a[N], T, n; +inline int ID(ll x) { return x <= T ? id1[x] : id2[n / x]; } +inline ll calc(ll x) { return x * (x + 1) / 2 - 1; } +inline ll f(ll x) { return x; } +void initPrime() +{ + T = 1e5 + 50; + for (int i = 2; i <= T; i++) + { + if (!flag[i]) prime[++ncnt] = i, sum[ncnt] = sum[ncnt - 1] + i; + for (int j = 1; j <= ncnt && i * prime[j] <= T; j++) + { + flag[i * prime[j]] = 1; + if (i % prime[j] == 0) break; + } + } +} +void init() +{ + m = 0; + T = sqrt(n + 0.5); + for (ll l = 1; l <= n; l = n / (n / l) + 1) + { + a[++m] = n / l; + if (a[m] <= T) + id1[a[m]] = m; + else + id2[n / a[m]] = m; + g[m] = calc(a[m]); + } + for (int i = 1; i <= ncnt; i++) + for (int j = 1; j <= m && (ll)prime[i] * prime[i] <= a[j]; j++) g[j] = g[j] - (ll)prime[i] * (g[ID(a[j] / prime[i])] - sum[i - 1]); +} +inline ll solve(ll x) +{ + if (x <= 1) return x; + return n = x, init(), g[ID(n)]; +} +} // namespace Min25 +ll calc1(ll _n, ll mod) +{ + __int128 x = _n; + return ((2 + x + 1) * x / 2 - 4) % mod; +} +int main() +{ + Min25::initPrime(); + int T; + ll __N, mod; + read(T); + while (T--) + { + read(__N, mod); + ll ans = calc1(__N, mod); + ans = ans + Min25::solve(__N + 1) % mod; + printf("%lld\n", ans % mod); + } + return 0; +} \ No newline at end of file diff --git a/java/1.java b/java/1.java deleted file mode 100644 index 67b73a7..0000000 --- a/java/1.java +++ /dev/null @@ -1,20 +0,0 @@ -import java.io.PrintStream; -import java.math.BigInteger; -import java.util.Scanner; -import java.util.StringTokenizer; - -class Main { - public static void main(String[] argv) { - String sp = System.getProperty("line.separator"); - PrintStream cout = System.out; - try (Scanner cin = new Scanner(System.in)) { - int T = cin.nextInt(); - for (int t = 1; t <= T; t++) { - BigInteger ba = cin.nextBigInteger(), bb = cin.nextBigInteger(); - cout.printf("Case %d:%s%s + %s = %s%s", t, sp, ba, bb, ba.add(bb), sp); - if (t != T) - cout.println(); - } - } - } -} \ No newline at end of file diff --git a/nowcoder7831/A.cpp b/nowcoder7831/A.cpp new file mode 100644 index 0000000..1df9da4 --- /dev/null +++ b/nowcoder7831/A.cpp @@ -0,0 +1,103 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +struct node +{ + int type; + union + { + char s[10]; + int v; + }; +}; +int cmp(const list &s1, const list &s2) +{ +} +list build(char *buf) +{ + list r; + for (char *p = buf; *p; p++) + { + + } + return r; +} +int main() +{ + int n; + read(n); + char buf[16]; + scanf("%s", buf); + auto s0 = build(buf); + for (int i = 0; i < n; i++) + { + scanf("%s", buf); + if (cmp(build(buf), s0)) + puts("+"); + else + puts("-"); + } + return 0; +} \ No newline at end of file diff --git a/nowcoder7831/A.py b/nowcoder7831/A.py new file mode 100644 index 0000000..b7f66fc --- /dev/null +++ b/nowcoder7831/A.py @@ -0,0 +1,32 @@ +import re + + +def proc(l): + r = [] + for v in l: + if v.isdigit(): + r.append(int(v)) + else: + for ch in v: + r.append(10**10 + ord(ch)) + r.append(-1) + return r + + +def cmp(a, b): + for i, j in zip(a, b): + if i < j: + return True + if i > j: + return False + + +spl = re.compile(r'(\d+|[a-zA-Z]+)') +n = int(input()) +s0 = proc(spl.findall(input())) +for i in range(n): + s = proc(spl.findall(input())) + if cmp(s, s0): + print('-') + else: + print('+') diff --git a/nowcoder7831/B.cpp b/nowcoder7831/B.cpp new file mode 100644 index 0000000..eb6dbcb --- /dev/null +++ b/nowcoder7831/B.cpp @@ -0,0 +1,88 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 1e5 + 50; +pair a[N]; +int b[N << 1]; +int presum[N << 1]; +int main() +{ + int n; + read(n); + for (int i = 0; i < n; i++) + read(a[i].first, a[i].second), b[i << 1] = a[i].first, b[i << 1 | 1] = a[i].second; + sort(b, b + n + n); + auto be = unique(b, b + n + n); + for (int i = 0; i < n; i++) + a[i].first = lower_bound(b, be, a[i].first) - b + 1, + a[i].second = lower_bound(b, be, a[i].second) - b + 1; + for (int i = 0; i < n; i++) + presum[a[i].first]++, presum[a[i].second]--; + for (int i = 1; i <= be - b; i++) + presum[i] += presum[i - 1]; + auto maxp = max_element(presum, presum + (be - b) + 1); + printf("%d %d", b[maxp - presum - 1], *maxp); + return 0; +} \ No newline at end of file diff --git a/nowcoder7831/CMakeLists.txt b/nowcoder7831/CMakeLists.txt new file mode 100644 index 0000000..b0c6690 --- /dev/null +++ b/nowcoder7831/CMakeLists.txt @@ -0,0 +1,8 @@ +project(nowcoder7831) +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++\\10.2.0\\x86_64-w64-mingw32") +add_executable(B B.cpp) \ No newline at end of file diff --git a/nowcoder7831/nowcoder7831.vcxproj b/nowcoder7831/nowcoder7831.vcxproj new file mode 100644 index 0000000..ff7761a --- /dev/null +++ b/nowcoder7831/nowcoder7831.vcxproj @@ -0,0 +1,89 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + + + + Application + true + v142 + + + Application + false + v142 + + + Application + true + v142 + + + Application + false + v142 + + + + + + + + + + + + + + + + + + + + + + + + + + + + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) + MultiThreaded + MultiThreadedDebug + + + + D:\PortableApps\MSYS2\mingw64\include\c++\10.2.0\x86_64-w64-mingw32;$(IncludePath) + + + x86-windows-static + x64-windows-static + {AFFB95BF-30B4-4DFB-B1F1-98F24D67BD64} + + + + + + \ No newline at end of file diff --git a/nw/sock/client.py b/nw/sock/client.py deleted file mode 100644 index 8a0ee7c..0000000 --- a/nw/sock/client.py +++ /dev/null @@ -1,11 +0,0 @@ -from socket import * -from struct import * - -while True: - st = input(">>> ") - s = socket(AF_INET, SOCK_STREAM) - s.connect(("127.0.0.1", 8888)) - s.sendall(pack("!i", len(st.encode()))) - s.sendall(st.encode()) - print(s.recv(len(st)).decode()) - s.close() \ No newline at end of file diff --git a/nw/sock/server.py b/nw/sock/server.py deleted file mode 100644 index 7b829f1..0000000 --- a/nw/sock/server.py +++ /dev/null @@ -1,18 +0,0 @@ -from socket import * -from struct import * -from threading import * -s = socket(AF_INET, SOCK_STREAM) -s.bind(('', 8888)) -s.listen(100) - - -def proc(cs): - msglen = unpack("!i", cs.recv(4))[0] - msg = cs.recv(msglen) - cs.sendall(msg.decode().upper().encode()) - - -while True: - (cs, addr) = s.accept() - # Thread(None, proc, args=(cs, )).start() - proc(cs) diff --git a/str/presentation.pdf b/str/presentation.pdf deleted file mode 100644 index 6122d89..0000000 Binary files a/str/presentation.pdf and /dev/null differ diff --git a/tmpl2020/Graph.cpp b/tmpl2020/Graph.cpp deleted file mode 100644 index a047e36..0000000 --- a/tmpl2020/Graph.cpp +++ /dev/null @@ -1,19 +0,0 @@ -template -struct Graph -{ - // Basic - struct Edge - { - int nxt, to, len; - }; - int adj[N], ecnt; - Edge E[M]; - void addEdge(int f, int t, int l) - { - E[++ecnt] = {adj[f], t, l}; - adj[f] = ecnt; - } - // Dijkstra - - // ISAP -}; \ No newline at end of file diff --git a/whu2020/A.cpp b/whu2020/A.cpp new file mode 100644 index 0000000..1a55cd2 --- /dev/null +++ b/whu2020/A.cpp @@ -0,0 +1,101 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 1e5 + 50; +int a[N]; +int main() +{ + int T, n, m; + read(T); + while (T--) + { + read(n, m); + for (int i = 0; i < n; i++) read(a[i]); + int p = *a; + sort(a, a + n); + int pos = lower_bound(a, a + n, p) - a; + int pos2 = upper_bound(a, a + n, p) - a; + a[pos]++, m--; + for (int i = n - 1; i >= pos2; i--) + { + if (m == 0) break; + a[i]++, m--; + } + for (int i = 0; i < pos; i++) + { + if (m == 0) break; + a[i]++, m--; + } + for (int i = pos + 1; i < pos2; i++) + { + if (m == 0) break; + a[i]++, m--; + } + sort(a, a + n); + int pos3 = lower_bound(a, a + n, p + 1) - a; + printf("%d\n", n - pos3); + } + return 0; +} \ No newline at end of file diff --git a/whu2020/D.cpp b/whu2020/D.cpp new file mode 100644 index 0000000..cebf742 --- /dev/null +++ b/whu2020/D.cpp @@ -0,0 +1,77 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + ll mod = 1e9 + 7; + ll n, a, b; + read(n); + while (n--) + { + read(a, b); + printf("%lld\n", b * fpow(2, a - 1, mod) % mod); + } + return 0; +} \ No newline at end of file diff --git a/whu2020/E.cpp b/whu2020/E.cpp new file mode 100644 index 0000000..d914ea5 --- /dev/null +++ b/whu2020/E.cpp @@ -0,0 +1,77 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 1050; +int a[N][N]; +int main() +{ + int n; + read(n); + INF(a); + for (int i = 1; i < n; i++) + for (int j = 1; j < n; j++) + read(a[i][j]); + return 0; +} \ No newline at end of file diff --git a/whu2020/F.py b/whu2020/F.py new file mode 100644 index 0000000..163b343 --- /dev/null +++ b/whu2020/F.py @@ -0,0 +1,27 @@ +import string +from collections import defaultdict +a = input() +b = input() +n = int(input()) +mps = [] +mp1 = defaultdict(int) +mp2 = defaultdict(int) +for ch in string.ascii_letters: + mp1[ch] = a.count(ch) + mp2[ch] = b.count(ch) +mps.append(mp1) +mps.append(mp2) +for i in range(2, n): + nmp = {} + for ch in string.ascii_letters: + nmp[ch] = mps[-1][ch] + mps[-2][ch] + mps.append(nmp) +if n == 1: + amp = mp1 +elif n == 2: + amp = mp2 +else: + amp = mps[-1] +for ch in string.ascii_uppercase + string.ascii_lowercase: + if amp[ch] > 0: + print(ch + ": " + str(amp[ch])) \ No newline at end of file