From 70e024b43b1794a64b39832f88f097821f7091f5 Mon Sep 17 00:00:00 2001 From: TooYoungTooSimp <6648049+TooYoungTooSimp@users.noreply.github.com> Date: Mon, 12 Aug 2019 18:52:21 +0800 Subject: [PATCH] Mon, 12 Aug 2019 18:52:21 +0800 --- cf1200/A.cpp | 50 +++++++++++++++++++++++ cf1200/B.cpp | 40 +++++++++++++++++++ cf1200/C.cpp | 30 ++++++++++++++ cf1200/CMakeLists.txt | 12 ++++++ cf1200/D.cpp | 50 +++++++++++++++++++++++ cf1200/E.cpp | 30 ++++++++++++++ cf1200/F.cpp | 19 +++++++++ hdu854/01.cpp | 19 +++++++++ hdu854/02.cpp | 19 +++++++++ hdu854/03.cpp | 19 +++++++++ hdu854/04.cpp | 19 +++++++++ hdu854/05.cpp | 19 +++++++++ hdu854/06.cpp | 40 +++++++++++++++++++ hdu854/07.cpp | 19 +++++++++ hdu854/08.cpp | 19 +++++++++ hdu854/09.cpp | 19 +++++++++ hdu854/10.cpp | 19 +++++++++ hdu854/11.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++ hdu854/CMakeLists.txt | 17 ++++++++ 19 files changed, 552 insertions(+) create mode 100644 cf1200/A.cpp create mode 100644 cf1200/B.cpp create mode 100644 cf1200/C.cpp create mode 100644 cf1200/CMakeLists.txt create mode 100644 cf1200/D.cpp create mode 100644 cf1200/E.cpp create mode 100644 cf1200/F.cpp create mode 100644 hdu854/01.cpp create mode 100644 hdu854/02.cpp create mode 100644 hdu854/03.cpp create mode 100644 hdu854/04.cpp create mode 100644 hdu854/05.cpp create mode 100644 hdu854/06.cpp create mode 100644 hdu854/07.cpp create mode 100644 hdu854/08.cpp create mode 100644 hdu854/09.cpp create mode 100644 hdu854/10.cpp create mode 100644 hdu854/11.cpp create mode 100644 hdu854/CMakeLists.txt diff --git a/cf1200/A.cpp b/cf1200/A.cpp new file mode 100644 index 0000000..3a6a978 --- /dev/null +++ b/cf1200/A.cpp @@ -0,0 +1,50 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +const int N = 1e5 + 50; +char s[N]; +bool r[10]; +int main() +{ + int n; + scanf("%d%s", &n, s); + for (int i = 0; i < n; i++) + { + switch (s[i]) + { + case 'L': + for (int i = 0; i <= 9; i++) + if (!r[i]) + { + r[i] = true; + break; + } + break; + case 'R': + for (int i = 9; i >= 0; i--) + if (!r[i]) + { + r[i] = true; + break; + } + break; + default: + r[s[i] - '0'] = false; + break; + } + } + for (int i = 0; i < 10; i++) putchar('0' + r[i]); + return 0; +} \ No newline at end of file diff --git a/cf1200/B.cpp b/cf1200/B.cpp new file mode 100644 index 0000000..e15640c --- /dev/null +++ b/cf1200/B.cpp @@ -0,0 +1,40 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +const int N = 1e6 + 60; +int h[N]; +int main() +{ + int T, n, m, k; + scanf("%d", &T); + while (T--) + { + scanf("%d%d%d", &n, &m, &k); + for (int i = 0; i < n; i++) scanf("%d", h + i); + bool flag = true; + for (int i = 0; i < n - 1; i++) + { + int target = max(0, h[i + 1] - k); + if (h[i] + m < target) + { + flag = false; + break; + } + m += h[i] - target; + } + puts(flag ? "YES" : "NO"); + } + return 0; +} \ No newline at end of file diff --git a/cf1200/C.cpp b/cf1200/C.cpp new file mode 100644 index 0000000..da39712 --- /dev/null +++ b/cf1200/C.cpp @@ -0,0 +1,30 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } +int main() +{ + ll n, m, q, sx, sy, ex, ey; + scanf("%lld%lld%lld", &n, &m, &q); + ll g = gcd(n, m); + while (q--) + { + scanf("%lld%lld%lld%lld", &sx, &sy, &ex, &ey); + int blkid1 = (sy - 1) / ((sx == 1 ? n : m) / g); + int blkid2 = (ey - 1) / ((ex == 1 ? n : m) / g); + puts(blkid1 == blkid2 ? "YES" : "NO"); + } + return 0; +} \ No newline at end of file diff --git a/cf1200/CMakeLists.txt b/cf1200/CMakeLists.txt new file mode 100644 index 0000000..bc0a826 --- /dev/null +++ b/cf1200/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(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) diff --git a/cf1200/D.cpp b/cf1200/D.cpp new file mode 100644 index 0000000..6fecb3d --- /dev/null +++ b/cf1200/D.cpp @@ -0,0 +1,50 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +const int N = 2005; +char buf[N][N]; +int a[N][N]; +int main() +{ + int n, k; + scanf("%d%d", &n, &k); + for (int i = 0; i < n; i++) scanf("%s", buf + i); + for (int i = 1; i <= n; i++) + for (int j = 1; j <= n; j++) + a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + (buf[i - 1][j - 1] == 'B'); + int ans = 0; + for (int i = 1; i <= n - k + 1; i++) + for (int j = 1; j <= n - k + 1; j++) + { + int cur = 0; + for (int l = 1; l <= n; l++) + { + int cnt = a[l][n] - a[l - 1][n]; + if (i <= l && l <= i + k - 1) + cnt -= a[l][j + k - 1] - a[l][j - 1] - a[l - 1][j + k - 1] + a[l - 1][j - 1]; + if (cnt == 0) cur++; + } + for (int l = 1; l <= n; l++) + { + int cnt = a[n][l] - a[n][l - 1]; + if (j <= l && l <= j + k - 1) + cnt -= a[i + k - 1][l] - a[i - 1][l] - a[i + k - 1][l - 1] + a[i - 1][l - 1]; + if (cnt == 0) cur++; + } + ans = max(ans, cur); + } + printf("%d", ans); + return 0; +} \ No newline at end of file diff --git a/cf1200/E.cpp b/cf1200/E.cpp new file mode 100644 index 0000000..8026b18 --- /dev/null +++ b/cf1200/E.cpp @@ -0,0 +1,30 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +const int N = 1e6 + 60; +char ans[N], buf[N], an; +int main() +{ + int n; + scanf("%d", &n); + while (n--) + { + scanf("%s", buf); + int len = strlen(buf); + + } + puts(ans); + return 0; +} \ No newline at end of file diff --git a/cf1200/F.cpp b/cf1200/F.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/cf1200/F.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/01.cpp b/hdu854/01.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/01.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/02.cpp b/hdu854/02.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/02.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/03.cpp b/hdu854/03.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/03.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/04.cpp b/hdu854/04.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/04.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/05.cpp b/hdu854/05.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/05.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/06.cpp b/hdu854/06.cpp new file mode 100644 index 0000000..c671ee1 --- /dev/null +++ b/hdu854/06.cpp @@ -0,0 +1,40 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +template +inline void read(T &x) +{ + int ch = x = 0; + while (!isdigit(ch)) ch = getchar(); + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; +} +int main() +{ + ll t, n, m, k; + read(t); + while (t--) + { + read(n), read(m), read(k); + if (k == n) + printf("%lld\n", n * (m + 1)); + else + { + ll base = m / n; + ll cnt = (n - m % n) % n; + printf("%lld\n", base * k + max(0ll, k - cnt) + k); + } + } + return 0; +} \ No newline at end of file diff --git a/hdu854/07.cpp b/hdu854/07.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/07.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/08.cpp b/hdu854/08.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/08.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/09.cpp b/hdu854/09.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/09.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/10.cpp b/hdu854/10.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu854/10.cpp @@ -0,0 +1,19 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(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 long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu854/11.cpp b/hdu854/11.cpp new file mode 100644 index 0000000..3b03e9b --- /dev/null +++ b/hdu854/11.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(tr, op, t, x) tr operator op(CRP(t, x)) const +#define OPL(t, x) OPX(bool, <, t, x) +#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 long long ll, i64; +ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } +const ll mod = 1e9 + 7; +inline ll fpow(ll a, ll b) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % mod) + if (b & 1) + r = r * a % mod; + return r; +} +inline ll inv(ll x) { return fpow(x, mod - 2); } +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + S; + return S == T ? EOF : *S++; +} +template +inline typename enable_if::value>::type read(T &x) +{ + int ch = x = 0; + while (!isdigit(ch)) ch = getchar(0); + for (; isdigit(ch); ch = getchar(0)) x = x * 10 + ch - '0'; +} +const int N = 5e5 + 50; +ll r[N], s[N], x[N], a[N]; +struct frac +{ + ll h, l; + OPX(frac, +, frac, rhs) + { + return frac{h * rhs.l + l * rhs.h, l * rhs.l}.reduce(); + } + OPX(frac, -, frac, rhs) + { + return frac{h * rhs.l + l * -rhs.h, l * rhs.l}.reduce(); + } + OPX(frac, *, frac, rhs) + { + return frac{h * rhs.h, l * rhs.l}.reduce(); + } + OPX(frac, /, frac, rhs) + { + return frac{h * rhs.l, l * rhs.h}.reduce(); + } + frac &reduce() + { + if (l == 0) l = 1; + ll g = gcd(h, l); + if (g > 1) h /= g, l /= g; + return *this; + } + void print() + { + reduce(); + printf("%lld\n", ll(h * inv(l) % mod)); + } +}; +frac psum[N]; +int main() +{ + int T, n, q; + read(T); + while (T--) + { + read(n), read(q); + for (int i = 1; i <= n; i++) read(r[i]), read(s[i]), read(x[i]), read(a[i]); + psum[0] = psum[1] = {0, 1}; + for (int i = 1; i <= n; i++) + psum[i + 1] = psum[i] + + frac{a[i], 1} * frac{s[i], r[i]} + + (psum[i] - psum[x[i]]) * frac{s[i] - r[i], r[i]}; + for (int i = 1, l, r; i <= q; i++) + read(l), read(r), (psum[r] - psum[l]).print(); + } + return 0; +} \ No newline at end of file diff --git a/hdu854/CMakeLists.txt b/hdu854/CMakeLists.txt new file mode 100644 index 0000000..1198974 --- /dev/null +++ b/hdu854/CMakeLists.txt @@ -0,0 +1,17 @@ +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(01 01.cpp) +add_executable(02 02.cpp) +add_executable(03 03.cpp) +add_executable(04 04.cpp) +add_executable(05 05.cpp) +add_executable(06 06.cpp) +add_executable(07 07.cpp) +add_executable(08 08.cpp) +add_executable(09 09.cpp) +add_executable(10 10.cpp) +add_executable(11 11.cpp)