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/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/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