From 60214bc8d0cfa68c1e3b74b62d9dcd1f548390eb Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sun, 24 Sep 2023 21:04:29 +0300 Subject: Solved 5 problem in the last Div.4 --- contests/Round896/A/main.cpp | 149 +++++++++++++++++++++++++++++ contests/Round896/A/main_input0.txt | 13 +++ contests/Round896/A/main_output0.txt | 20 ++++ contests/Round896/B/main.cpp | 176 +++++++++++++++++++++++++++++++++++ contests/Round896/B/main_input0.txt | 28 ++++++ contests/Round896/B/main_input1.txt | 9 ++ contests/Round896/B/main_output0.txt | 5 + contests/Round896/B/main_output1.txt | 1 + contests/Round896/C/main.cpp | 129 +++++++++++++++++++++++++ contests/Round896/D/main.cpp | 129 +++++++++++++++++++++++++ contests/Round896/E/main.cpp | 129 +++++++++++++++++++++++++ contests/Round896/F/main.cpp | 129 +++++++++++++++++++++++++ contests/Round897/A/main.cpp | 146 +++++++++++++++++++++++++++++ contests/Round897/A/main_input0.txt | 7 ++ contests/Round897/A/main_input1.txt | 3 + contests/Round897/A/main_input2.txt | 3 + contests/Round897/A/main_output0.txt | 3 + contests/Round897/A/main_output1.txt | 1 + contests/Round897/A/main_output2.txt | 1 + contests/Round897/B/main.cpp | 165 ++++++++++++++++++++++++++++++++ contests/Round897/B/main_input0.txt | 11 +++ contests/Round897/B/main_input1.txt | 3 + contests/Round897/B/main_output0.txt | 5 + contests/Round897/B/main_output1.txt | 1 + contests/Round897/C/main.cpp | 129 +++++++++++++++++++++++++ contests/Round897/D/main.cpp | 129 +++++++++++++++++++++++++ contests/Round897/E/main.cpp | 129 +++++++++++++++++++++++++ contests/Round897/F/main.cpp | 129 +++++++++++++++++++++++++ contests/Round898/A/main.cpp | 143 ++++++++++++++++++++++++++++ contests/Round898/A/main_input0.txt | 7 ++ contests/Round898/A/main_output0.txt | 6 ++ contests/Round898/B/main.cpp | 147 +++++++++++++++++++++++++++++ contests/Round898/B/main_input0.txt | 9 ++ contests/Round898/B/main_output0.txt | 4 + contests/Round898/C/main.cpp | 163 ++++++++++++++++++++++++++++++++ contests/Round898/C/main_input0.txt | 41 ++++++++ contests/Round898/C/main_output0.txt | 4 + contests/Round898/D/main.cpp | 146 +++++++++++++++++++++++++++++ contests/Round898/D/main_input0.txt | 17 ++++ contests/Round898/D/main_output0.txt | 8 ++ contests/Round898/E/main.cpp | 157 +++++++++++++++++++++++++++++++ contests/Round898/E/main_input0.txt | 11 +++ contests/Round898/E/main_output0.txt | 5 + contests/Round898/F/main.cpp | 165 ++++++++++++++++++++++++++++++++ contests/Round898/F/main_input0.txt | 16 ++++ contests/Round898/F/main_output0.txt | 5 + contests/Round898/G/main.cpp | 161 ++++++++++++++++++++++++++++++++ contests/Round898/G/main_input0.txt | 9 ++ contests/Round898/G/main_output0.txt | 8 ++ 49 files changed, 3014 insertions(+) create mode 100755 contests/Round896/A/main.cpp create mode 100644 contests/Round896/A/main_input0.txt create mode 100644 contests/Round896/A/main_output0.txt create mode 100755 contests/Round896/B/main.cpp create mode 100644 contests/Round896/B/main_input0.txt create mode 100644 contests/Round896/B/main_input1.txt create mode 100644 contests/Round896/B/main_output0.txt create mode 100644 contests/Round896/B/main_output1.txt create mode 100755 contests/Round896/C/main.cpp create mode 100755 contests/Round896/D/main.cpp create mode 100755 contests/Round896/E/main.cpp create mode 100755 contests/Round896/F/main.cpp create mode 100755 contests/Round897/A/main.cpp create mode 100644 contests/Round897/A/main_input0.txt create mode 100644 contests/Round897/A/main_input1.txt create mode 100644 contests/Round897/A/main_input2.txt create mode 100644 contests/Round897/A/main_output0.txt create mode 100644 contests/Round897/A/main_output1.txt create mode 100644 contests/Round897/A/main_output2.txt create mode 100755 contests/Round897/B/main.cpp create mode 100644 contests/Round897/B/main_input0.txt create mode 100644 contests/Round897/B/main_input1.txt create mode 100644 contests/Round897/B/main_output0.txt create mode 100644 contests/Round897/B/main_output1.txt create mode 100755 contests/Round897/C/main.cpp create mode 100755 contests/Round897/D/main.cpp create mode 100755 contests/Round897/E/main.cpp create mode 100755 contests/Round897/F/main.cpp create mode 100755 contests/Round898/A/main.cpp create mode 100644 contests/Round898/A/main_input0.txt create mode 100644 contests/Round898/A/main_output0.txt create mode 100755 contests/Round898/B/main.cpp create mode 100644 contests/Round898/B/main_input0.txt create mode 100644 contests/Round898/B/main_output0.txt create mode 100755 contests/Round898/C/main.cpp create mode 100644 contests/Round898/C/main_input0.txt create mode 100644 contests/Round898/C/main_output0.txt create mode 100755 contests/Round898/D/main.cpp create mode 100644 contests/Round898/D/main_input0.txt create mode 100644 contests/Round898/D/main_output0.txt create mode 100755 contests/Round898/E/main.cpp create mode 100644 contests/Round898/E/main_input0.txt create mode 100644 contests/Round898/E/main_output0.txt create mode 100755 contests/Round898/F/main.cpp create mode 100644 contests/Round898/F/main_input0.txt create mode 100644 contests/Round898/F/main_output0.txt create mode 100644 contests/Round898/G/main.cpp create mode 100644 contests/Round898/G/main_input0.txt create mode 100644 contests/Round898/G/main_output0.txt (limited to 'contests') diff --git a/contests/Round896/A/main.cpp b/contests/Round896/A/main.cpp new file mode 100755 index 0000000..233430e --- /dev/null +++ b/contests/Round896/A/main.cpp @@ -0,0 +1,149 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { + int n; + cin >> n; + vi v(n); + for (auto &x : v) { + cin >> x; + } + int s = 0; + if (n % 2 == 0) { + cout << 2 << '\n'; + cout << 1 << ' ' << n << '\n'; + cout << 1 << ' ' << n << '\n'; + } else { + // 0 0 0 0 9 + cout << 4 << '\n'; + cout << 1 << ' ' << n << '\n'; + cout << 1 << ' ' << n - 1 << '\n'; + cout << n - 1 << ' ' << n << '\n'; + cout << n - 1 << ' ' << n << '\n'; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round896/A/main_input0.txt b/contests/Round896/A/main_input0.txt new file mode 100644 index 0000000..46d71ff --- /dev/null +++ b/contests/Round896/A/main_input0.txt @@ -0,0 +1,13 @@ +6 +4 +1 2 3 0 +8 +3 1 4 1 5 9 2 6 +6 +1 5 4 1 4 7 +5 +0 0 0 0 0 +7 +1 1 9 9 0 1 8 +3 +100 100 0 diff --git a/contests/Round896/A/main_output0.txt b/contests/Round896/A/main_output0.txt new file mode 100644 index 0000000..93cdabc --- /dev/null +++ b/contests/Round896/A/main_output0.txt @@ -0,0 +1,20 @@ +1 +1 4 +2 +4 7 +1 8 +6 +1 2 +3 4 +5 6 +1 3 +4 6 +1 6 +0 +4 +1 2 +6 7 +3 4 +6 7 +1 +1 2 diff --git a/contests/Round896/B/main.cpp b/contests/Round896/B/main.cpp new file mode 100755 index 0000000..e029c65 --- /dev/null +++ b/contests/Round896/B/main.cpp @@ -0,0 +1,176 @@ +#include +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +// (-1, 3) -> (-3, -3) = 2 + 6 = 8 +// (-1, 3) -> (-2, 3) -> (-3, -3) = 1 + 0 + 1 + 6 = 8 + +void solve() { + int n, k, a, b; + cin >> n >> k >> a >> b; + vector> v(n, vector(2)); + for (int i = 0; i < n; i++) { + cin >> v[i][0] >> v[i][1]; + } + if (a <= k && b <= k) { + cout << 0 << '\n'; + return; + } + a--; + b--; + int idx_e = 0; + ll mn_end = INT_MAX; + for (int i = 0; i < n; i++) { + if (i != b && mn_end > abs(v[b][0] - v[i][0]) + abs(v[b][1] - v[i][1])) { + idx_e = i; + mn_end = min(mn_end, abs(v[b][0] - v[i][0]) + abs(v[b][1] - v[i][1])); + } + } + int idx_a = 0; + ll mn = INT_MAX; + for (int i = 0; i < k; i++) { + if (i != idx_e && + mn > abs(v[idx_e][0] - v[i][0]) + abs(v[idx_e][1] - v[i][1])) { + idx_a = i; + mn = min(mn, abs(v[idx_e][0] - v[i][0]) + abs(v[idx_e][1] - v[i][1])); + } + } + ll ans = 0; + if (idx_a + 1 <= k && idx_e + 1 <= k) { + if (idx_a + 1 > k || a + 1 > k) { + ans += abs(v[idx_a][0] - v[a][0]) + abs(v[idx_a][1] - v[a][1]); + } + } else { + ans += abs(v[a][0] - v[idx_e][0]) + abs(v[a][1] - v[idx_e][1]); + } + + if (idx_e + 1 > k || b + 1 > k) { + ans += abs(v[b][0] - v[idx_e][0]) + abs(v[b][1] - v[idx_e][1]); + } + cout << ans << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round896/B/main_input0.txt b/contests/Round896/B/main_input0.txt new file mode 100644 index 0000000..e71b84a --- /dev/null +++ b/contests/Round896/B/main_input0.txt @@ -0,0 +1,28 @@ +5 +6 2 3 5 +0 0 +1 -2 +-2 1 +-1 3 +2 -2 +-3 -3 +2 0 1 2 +-1000000000 -1000000000 +1000000000 1000000000 +7 5 4 2 +154 147 +-154 -147 +123 456 +20 23 +43 20 +998 244 +353 100 +3 1 3 1 +0 10 +1 20 +2 30 +4 3 2 4 +0 0 +-100 100 +-1 -1 +-1 0 diff --git a/contests/Round896/B/main_input1.txt b/contests/Round896/B/main_input1.txt new file mode 100644 index 0000000..551cc43 --- /dev/null +++ b/contests/Round896/B/main_input1.txt @@ -0,0 +1,9 @@ +1 +7 2 3 5 +0 0 +1 -2 +-2 1 +-1 3 +1 -2 +2 -2 +-3 -3 \ No newline at end of file diff --git a/contests/Round896/B/main_output0.txt b/contests/Round896/B/main_output0.txt new file mode 100644 index 0000000..d434c75 --- /dev/null +++ b/contests/Round896/B/main_output0.txt @@ -0,0 +1,5 @@ +4 +4000000000 +0 +22 +1 diff --git a/contests/Round896/B/main_output1.txt b/contests/Round896/B/main_output1.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/contests/Round896/B/main_output1.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/contests/Round896/C/main.cpp b/contests/Round896/C/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round896/C/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round896/D/main.cpp b/contests/Round896/D/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round896/D/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round896/E/main.cpp b/contests/Round896/E/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round896/E/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round896/F/main.cpp b/contests/Round896/F/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round896/F/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round897/A/main.cpp b/contests/Round897/A/main.cpp new file mode 100755 index 0000000..7f5ebac --- /dev/null +++ b/contests/Round897/A/main.cpp @@ -0,0 +1,146 @@ +#include +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { + int n; + cin >> n; + vector v(n); + vi b(n); + for (int i = 0; i < n; i++) { + cin >> v[i].first; + v[i].second = i; + } + sort(rall(v)); + for (int i = 0; i < n; i++) { + b[v[i].second] = i + 1; + } + for (int i = 0; i < n; i++) { + cout << b[i] << " \n"[i == n - 1]; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round897/A/main_input0.txt b/contests/Round897/A/main_input0.txt new file mode 100644 index 0000000..5ffc211 --- /dev/null +++ b/contests/Round897/A/main_input0.txt @@ -0,0 +1,7 @@ +3 +1 +100000 +2 +1 1 +3 +10 3 3 diff --git a/contests/Round897/A/main_input1.txt b/contests/Round897/A/main_input1.txt new file mode 100644 index 0000000..e598f55 --- /dev/null +++ b/contests/Round897/A/main_input1.txt @@ -0,0 +1,3 @@ +1 +5 +8 7 6 5 3 \ No newline at end of file diff --git a/contests/Round897/A/main_input2.txt b/contests/Round897/A/main_input2.txt new file mode 100644 index 0000000..05d1ebb --- /dev/null +++ b/contests/Round897/A/main_input2.txt @@ -0,0 +1,3 @@ +1 +5 +9 5 3 7 4 \ No newline at end of file diff --git a/contests/Round897/A/main_output0.txt b/contests/Round897/A/main_output0.txt new file mode 100644 index 0000000..bd92684 --- /dev/null +++ b/contests/Round897/A/main_output0.txt @@ -0,0 +1,3 @@ +1 +2 1 +1 3 2 diff --git a/contests/Round897/A/main_output1.txt b/contests/Round897/A/main_output1.txt new file mode 100644 index 0000000..3cacc0b --- /dev/null +++ b/contests/Round897/A/main_output1.txt @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/contests/Round897/A/main_output2.txt b/contests/Round897/A/main_output2.txt new file mode 100644 index 0000000..a5b4030 --- /dev/null +++ b/contests/Round897/A/main_output2.txt @@ -0,0 +1 @@ +1 3 5 2 4 \ No newline at end of file diff --git a/contests/Round897/B/main.cpp b/contests/Round897/B/main.cpp new file mode 100755 index 0000000..ad96ddc --- /dev/null +++ b/contests/Round897/B/main.cpp @@ -0,0 +1,165 @@ +#include +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +// ones = 2 +// zrs = 4 +// 2 -> (0, 6) +// 3 -> (3, 3) +// 3 -> (3, 3) +// ones = 1 +// zrs = 1 + +void solve() { + int n; + cin >> n; + string s; + cin >> s; + int mn = 0, mx = n % 2; + for (int i = 0; i < n / 2; i++) { + if (s[i] == s[n - 1 - i]) { + mn += 0; + mx += 2; + } else { + mn += 1; + mx += 1; + } + } + dbg(mn, mx); + string ans = string(n + 1, '0'); + if (n % 2 == 0) { + for (int i = mn; i <= mx; i += 2) { + ans[i] = '1'; + } + } else { + for (int i = mn; i <= mx; i++) { + ans[i] = '1'; + } + } + cout << ans << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round897/B/main_input0.txt b/contests/Round897/B/main_input0.txt new file mode 100644 index 0000000..10a3274 --- /dev/null +++ b/contests/Round897/B/main_input0.txt @@ -0,0 +1,11 @@ +5 +6 +101011 +5 +00000 +9 +100100011 +3 +100 +1 +1 diff --git a/contests/Round897/B/main_input1.txt b/contests/Round897/B/main_input1.txt new file mode 100644 index 0000000..c64122e --- /dev/null +++ b/contests/Round897/B/main_input1.txt @@ -0,0 +1,3 @@ +1 +2 +10 \ No newline at end of file diff --git a/contests/Round897/B/main_output0.txt b/contests/Round897/B/main_output0.txt new file mode 100644 index 0000000..ad36f78 --- /dev/null +++ b/contests/Round897/B/main_output0.txt @@ -0,0 +1,5 @@ +0010100 +111111 +0011111100 +0110 +11 diff --git a/contests/Round897/B/main_output1.txt b/contests/Round897/B/main_output1.txt new file mode 100644 index 0000000..fd594a5 --- /dev/null +++ b/contests/Round897/B/main_output1.txt @@ -0,0 +1 @@ +000 \ No newline at end of file diff --git a/contests/Round897/C/main.cpp b/contests/Round897/C/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round897/C/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round897/D/main.cpp b/contests/Round897/D/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round897/D/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round897/E/main.cpp b/contests/Round897/E/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round897/E/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round897/F/main.cpp b/contests/Round897/F/main.cpp new file mode 100755 index 0000000..82c5879 --- /dev/null +++ b/contests/Round897/F/main.cpp @@ -0,0 +1,129 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { <()> } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round898/A/main.cpp b/contests/Round898/A/main.cpp new file mode 100755 index 0000000..a6c5585 --- /dev/null +++ b/contests/Round898/A/main.cpp @@ -0,0 +1,143 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { + string s; + cin >> s; + string tmp1 = s; + string tmp2 = s; + string tmp3 = s; + swap(tmp1[0], tmp1[1]); + swap(tmp2[0], tmp2[2]); + swap(tmp3[1], tmp3[2]); + if (s == "abc" || tmp1 == "abc" || tmp2 == "abc" || tmp3 == "abc") { + cout << "YES\n"; + } else { + cout << "NO\n"; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round898/A/main_input0.txt b/contests/Round898/A/main_input0.txt new file mode 100644 index 0000000..67b9fb9 --- /dev/null +++ b/contests/Round898/A/main_input0.txt @@ -0,0 +1,7 @@ +6 +abc +acb +bac +bca +cab +cba diff --git a/contests/Round898/A/main_output0.txt b/contests/Round898/A/main_output0.txt new file mode 100644 index 0000000..d8b63f9 --- /dev/null +++ b/contests/Round898/A/main_output0.txt @@ -0,0 +1,6 @@ +YES +YES +YES +NO +NO +YES diff --git a/contests/Round898/B/main.cpp b/contests/Round898/B/main.cpp new file mode 100755 index 0000000..66112a9 --- /dev/null +++ b/contests/Round898/B/main.cpp @@ -0,0 +1,147 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +void solve() { + int n; + cin >> n; + vll v(n); + for (auto &x : v) { + cin >> x; + } + ll mx = 0; + for (int i = 0; i < n; i++) { + vll tmp = v; + tmp[i]++; + ll sum = 1; + for (int j = 0; j < n; j++) { + sum *= tmp[j]; + } + mx = max(mx, sum); + } + cout << mx << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round898/B/main_input0.txt b/contests/Round898/B/main_input0.txt new file mode 100644 index 0000000..246ddda --- /dev/null +++ b/contests/Round898/B/main_input0.txt @@ -0,0 +1,9 @@ +4 +4 +2 2 1 2 +3 +0 1 2 +5 +4 3 2 3 4 +9 +9 9 9 9 9 9 9 9 9 diff --git a/contests/Round898/B/main_output0.txt b/contests/Round898/B/main_output0.txt new file mode 100644 index 0000000..5ff12ca --- /dev/null +++ b/contests/Round898/B/main_output0.txt @@ -0,0 +1,4 @@ +16 +2 +432 +430467210 diff --git a/contests/Round898/C/main.cpp b/contests/Round898/C/main.cpp new file mode 100755 index 0000000..c27011c --- /dev/null +++ b/contests/Round898/C/main.cpp @@ -0,0 +1,163 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b)-1) / (b) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +bool is_ring(int i, int j, int ring) { + if (ring == 1) { + return i == 0 || i == 9 || j == 0 || j == 9; + } else if (ring == 2) { + return i == 1 || i == 8 || j == 1 || j == 8; + } else if (ring == 3) { + return i == 2 || i == 7 || j == 2 || j == 7; + } else if (ring == 4) { + return i == 3 || i == 6 || j == 3 || j == 6; + } else if (ring == 5) { + return i == 4 || i == 5 || j == 4 || j == 5; + } + return false; +} + +void solve() { + vector v(10); + for (auto &str : v) { + cin >> str; + } + int ans = 0; + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + if (v[i][j] == 'X') { + for (int k = 1; k <= 5; k++) { + if (is_ring(i, j, k)) { + ans += k; + break; + } + } + } + } + } + cout << ans << '\n'; +} + +int main() { + ios_base::sync_with_s