From 41ce2d5446f6f075eb8711fe1ec50b7d0e53e5f4 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Tue, 25 Jul 2023 21:47:54 +0300 Subject: Solved 3 problems in today's Div3 round --- codeforces/RudolphAndCutTheRope/main | Bin 0 -> 16624 bytes codeforces/RudolphAndCutTheRope/main.cpp | 139 +++++++++++++++ codeforces/RudolphAndCutTheRope/main_input0.txt | 20 +++ codeforces/RudolphAndCutTheRope/main_output0.txt | 4 + codeforces/RudolphAndTheAnotherCompetition/main | Bin 0 -> 62544 bytes .../RudolphAndTheAnotherCompetition/main.cpp | 196 +++++++++++++++++++++ .../main_input0.txt | 18 ++ .../main_input1.txt | 7 + .../main_input2.txt | 49 ++++++ .../main_output0.txt | 5 + .../main_output1.txt | 1 + .../main_output2.txt | 1 + codeforces/RudolphAndTicTacToe/main | Bin 0 -> 22152 bytes codeforces/RudolphAndTicTacToe/main.cpp | 177 +++++++++++++++++++ codeforces/RudolphAndTicTacToe/main_input0.txt | 16 ++ codeforces/RudolphAndTicTacToe/main_output0.txt | 5 + contests/Round888/A/main | Bin 0 -> 16624 bytes contests/Round888/A/main.cpp | 142 +++++++++++++++ contests/Round888/A/main_input0.txt | 15 ++ contests/Round888/A/main_output0.txt | 7 + contests/Round888/B/main | Bin 0 -> 52520 bytes contests/Round888/B/main.cpp | 146 +++++++++++++++ contests/Round888/B/main_input0.txt | 13 ++ contests/Round888/B/main_output0.txt | 6 + contests/Round888/C/main | Bin 0 -> 24680 bytes contests/Round888/C/main.cpp | 163 +++++++++++++++++ contests/Round888/C/main_input0.txt | 21 +++ contests/Round888/C/main_input1.txt | 3 + contests/Round888/C/main_input2.txt | 3 + contests/Round888/C/main_output0.txt | 10 ++ contests/Round888/C/main_output1.txt | 1 + contests/Round888/C/main_output2.txt | 1 + contests/Round888/D/main | Bin 0 -> 25896 bytes contests/Round888/D/main.cpp | 145 +++++++++++++++ contests/Round888/D/main_input0.txt | 25 +++ contests/Round888/D/main_output0.txt | 12 ++ 36 files changed, 1351 insertions(+) create mode 100755 codeforces/RudolphAndCutTheRope/main create mode 100755 codeforces/RudolphAndCutTheRope/main.cpp create mode 100644 codeforces/RudolphAndCutTheRope/main_input0.txt create mode 100644 codeforces/RudolphAndCutTheRope/main_output0.txt create mode 100755 codeforces/RudolphAndTheAnotherCompetition/main create mode 100755 codeforces/RudolphAndTheAnotherCompetition/main.cpp create mode 100644 codeforces/RudolphAndTheAnotherCompetition/main_input0.txt create mode 100644 codeforces/RudolphAndTheAnotherCompetition/main_input1.txt create mode 100644 codeforces/RudolphAndTheAnotherCompetition/main_input2.txt create mode 100644 codeforces/RudolphAndTheAnotherCompetition/main_output0.txt create mode 100644 codeforces/RudolphAndTheAnotherCompetition/main_output1.txt create mode 100644 codeforces/RudolphAndTheAnotherCompetition/main_output2.txt create mode 100755 codeforces/RudolphAndTicTacToe/main create mode 100755 codeforces/RudolphAndTicTacToe/main.cpp create mode 100644 codeforces/RudolphAndTicTacToe/main_input0.txt create mode 100644 codeforces/RudolphAndTicTacToe/main_output0.txt create mode 100755 contests/Round888/A/main create mode 100755 contests/Round888/A/main.cpp create mode 100644 contests/Round888/A/main_input0.txt create mode 100644 contests/Round888/A/main_output0.txt create mode 100755 contests/Round888/B/main create mode 100755 contests/Round888/B/main.cpp create mode 100644 contests/Round888/B/main_input0.txt create mode 100644 contests/Round888/B/main_output0.txt create mode 100755 contests/Round888/C/main create mode 100755 contests/Round888/C/main.cpp create mode 100644 contests/Round888/C/main_input0.txt create mode 100644 contests/Round888/C/main_input1.txt create mode 100644 contests/Round888/C/main_input2.txt create mode 100644 contests/Round888/C/main_output0.txt create mode 100644 contests/Round888/C/main_output1.txt create mode 100644 contests/Round888/C/main_output2.txt create mode 100755 contests/Round888/D/main create mode 100755 contests/Round888/D/main.cpp create mode 100644 contests/Round888/D/main_input0.txt create mode 100644 contests/Round888/D/main_output0.txt diff --git a/codeforces/RudolphAndCutTheRope/main b/codeforces/RudolphAndCutTheRope/main new file mode 100755 index 0000000..c5c066e Binary files /dev/null and b/codeforces/RudolphAndCutTheRope/main differ diff --git a/codeforces/RudolphAndCutTheRope/main.cpp b/codeforces/RudolphAndCutTheRope/main.cpp new file mode 100755 index 0000000..b48c704 --- /dev/null +++ b/codeforces/RudolphAndCutTheRope/main.cpp @@ -0,0 +1,139 @@ +#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; + int cnt = 0; + for (int i = 0; i < n; i++) { + int a, b; + cin >> a >> b; + cnt += (a > b); + } + cout << cnt << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/RudolphAndCutTheRope/main_input0.txt b/codeforces/RudolphAndCutTheRope/main_input0.txt new file mode 100644 index 0000000..521f3ef --- /dev/null +++ b/codeforces/RudolphAndCutTheRope/main_input0.txt @@ -0,0 +1,20 @@ +4 +3 +4 3 +3 1 +1 2 +4 +9 2 +5 2 +7 7 +3 4 +5 +11 7 +5 10 +12 9 +3 2 +1 5 +3 +5 6 +4 5 +7 7 diff --git a/codeforces/RudolphAndCutTheRope/main_output0.txt b/codeforces/RudolphAndCutTheRope/main_output0.txt new file mode 100644 index 0000000..8e7c5e0 --- /dev/null +++ b/codeforces/RudolphAndCutTheRope/main_output0.txt @@ -0,0 +1,4 @@ +2 +2 +3 +0 diff --git a/codeforces/RudolphAndTheAnotherCompetition/main b/codeforces/RudolphAndTheAnotherCompetition/main new file mode 100755 index 0000000..92b0413 Binary files /dev/null and b/codeforces/RudolphAndTheAnotherCompetition/main differ diff --git a/codeforces/RudolphAndTheAnotherCompetition/main.cpp b/codeforces/RudolphAndTheAnotherCompetition/main.cpp new file mode 100755 index 0000000..58246cf --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main.cpp @@ -0,0 +1,196 @@ +#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 + */ + +ll calc_penalty(vll &v, int b) { + ll penalty = 0; + ll pref = 0; + for (int i = 0; i < b; i++) { + pref += v[i]; + penalty += pref; + } + return penalty; +} + +int calc_problems(vll &v, int h) { + ll sum = 0; + for (int i = 0; i < v.size(); i++) { + if (sum + v[i] > h) { + return i; + } + sum += v[i]; + } + return v.size(); +} + +struct triple { + int pos; + int first; + ll second; +}; + +// operator overloading for == for the triple struct +bool operator==(const triple &p1, const triple &p2) { + return p1.first == p2.first && p1.second == p2.second; +} + +ostream &operator<<(ostream &os, const triple &tr) { + os << "\n {" << tr.first << ' ' << tr.second << ' ' << tr.pos << "}"; + return os; +} + +bool customComparator(triple &p1, triple &p2) { + if (p1.first > p2.first) + return true; + else if (p1.first == p2.first && p1.second == p2.second) { + return p1.pos == 0; + } else if (p1.first == p2.first) + return p1.second < p2.second; + return false; +} + +void solve() { + int n, m, h; + cin >> n >> m >> h; + vector mp(n); + for (int i = 0; i < n; i++) { + vll v(m); + for (auto &x : v) { + cin >> x; + } + sort(all(v)); + int b = calc_problems(v, h); + ll pen = calc_penalty(v, b); + mp[i] = {i, b, pen}; + } + sort(all(mp), customComparator); + for (int i = 0; i < n; i++) { + if (mp[i].pos == 0) { + cout << i + 1 << '\n'; + } + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/RudolphAndTheAnotherCompetition/main_input0.txt b/codeforces/RudolphAndTheAnotherCompetition/main_input0.txt new file mode 100644 index 0000000..6b18f43 --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main_input0.txt @@ -0,0 +1,18 @@ +5 +3 3 120 +20 15 110 +90 90 100 +40 40 40 +2 1 120 +30 +30 +1 3 120 +10 20 30 +3 2 27 +8 9 +10 7 +10 8 +3 3 15 +7 2 6 +7 5 4 +1 9 8 diff --git a/codeforces/RudolphAndTheAnotherCompetition/main_input1.txt b/codeforces/RudolphAndTheAnotherCompetition/main_input1.txt new file mode 100644 index 0000000..01faba6 --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main_input1.txt @@ -0,0 +1,7 @@ +1 +5 1 50 +1 +1 +1 +1 +1 \ No newline at end of file diff --git a/codeforces/RudolphAndTheAnotherCompetition/main_input2.txt b/codeforces/RudolphAndTheAnotherCompetition/main_input2.txt new file mode 100644 index 0000000..d3819c2 --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main_input2.txt @@ -0,0 +1,49 @@ +1 +47 3 129 +2 2 3 +4 1 2 +4 2 1 +3 2 4 +1 4 4 +1 2 1 +5 4 5 +6 4 5 +2 1 6 +5 5 3 +6 4 5 +4 5 6 +4 5 4 +3 6 3 +1 3 6 +2 4 4 +6 6 1 +5 6 3 +6 4 1 +1 5 2 +2 6 5 +2 6 5 +6 3 5 +1 3 4 +5 3 4 +1 1 3 +6 2 6 +2 5 4 +3 3 6 +5 4 2 +6 6 1 +6 3 2 +3 4 6 +1 1 4 +1 3 6 +2 1 4 +6 2 5 +1 6 6 +2 1 3 +4 2 6 +2 2 4 +6 5 2 +6 4 2 +6 3 6 +4 4 6 +6 5 6 +1 4 1 \ No newline at end of file diff --git a/codeforces/RudolphAndTheAnotherCompetition/main_output0.txt b/codeforces/RudolphAndTheAnotherCompetition/main_output0.txt new file mode 100644 index 0000000..df106a2 --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main_output0.txt @@ -0,0 +1,5 @@ +2 +1 +1 +2 +1 diff --git a/codeforces/RudolphAndTheAnotherCompetition/main_output1.txt b/codeforces/RudolphAndTheAnotherCompetition/main_output1.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main_output1.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/codeforces/RudolphAndTheAnotherCompetition/main_output2.txt b/codeforces/RudolphAndTheAnotherCompetition/main_output2.txt new file mode 100644 index 0000000..9a03714 --- /dev/null +++ b/codeforces/RudolphAndTheAnotherCompetition/main_output2.txt @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/codeforces/RudolphAndTicTacToe/main b/codeforces/RudolphAndTicTacToe/main new file mode 100755 index 0000000..a4f1dae Binary files /dev/null and b/codeforces/RudolphAndTicTacToe/main differ diff --git a/codeforces/RudolphAndTicTacToe/main.cpp b/codeforces/RudolphAndTicTacToe/main.cpp new file mode 100755 index 0000000..650f957 --- /dev/null +++ b/codeforces/RudolphAndTicTacToe/main.cpp @@ -0,0 +1,177 @@ +#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 isWinner(const vector &board, char player) { + // Check rows + for (int i = 0; i < 3; ++i) { + if (board[i][0] == player && board[i][1] == player && + board[i][2] == player) { + return true; + } + } + + // Check columns + for (int i = 0; i < 3; ++i) { + if (board[0][i] == player && board[1][i] == player && + board[2][i] == player) { + return true; + } + } + + // Check diagonals + if ((board[0][0] == player && board[1][1] == player && + board[2][2] == player) || + (board[0][2] == player && board[1][1] == player && + board[2][0] == player)) { + return true; + } + + return false; +} + +char checkWinner(const vector &board) { + for (char player : {'X', 'O', '+'}) { + if (isWinner(board, player)) { + return player; + } + } + return '.'; // '\0' represents no winner +} + +void solve() { + vector v(3); + for (int i = 0; i < 3; i++) { + cin >> v[i]; + } + char winner = checkWinner(v); + if (winner == '.') { + cout << "DRAW\n"; + } else { + cout << winner << "\n"; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/RudolphAndTicTacToe/main_input0.txt b/codeforces/RudolphAndTicTacToe/main_input0.txt new file mode 100644 index 0000000..f807a3a --- /dev/null +++ b/codeforces/RudolphAndTicTacToe/main_input0.txt @@ -0,0 +1,16 @@ +5 ++X+ +OXO +OX. +O+. ++OX +X+O +.XO +OX. ++++ +O.+ +X.O ++.. +.++ +X.O ++.. diff --git a/codeforces/RudolphAndTicTacToe/main_output0.txt b/codeforces/RudolphAndTicTacToe/main_output0.txt new file mode 100644 index 0000000..e1566f0 --- /dev/null +++ b/codeforces/RudolphAndTicTacToe/main_output0.txt @@ -0,0 +1,5 @@ +X +O ++ +DRAW +DRAW diff --git a/contests/Round888/A/main b/contests/Round888/A/main new file mode 100755 index 0000000..523c272 Binary files /dev/null and b/contests/Round888/A/main differ diff --git a/contests/Round888/A/main.cpp b/contests/Round888/A/main.cpp new file mode 100755 index 0000000..a661aba --- /dev/null +++ b/contests/Round888/A/main.cpp @@ -0,0 +1,142 @@ +#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, m, k, H; + cin >> n >> m >> k >> H; + int cnt = 0; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + int diff = abs(H - x); + if (diff > 0 && diff % k == 0 && (diff / k <= m - 1)) { + cnt++; + } + } + cout << cnt << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round888/A/main_input0.txt b/contests/Round888/A/main_input0.txt new file mode 100644 index 0000000..2b0b17d --- /dev/null +++ b/contests/Round888/A/main_input0.txt @@ -0,0 +1,15 @@ +7 +5 3 3 11 +5 4 14 18 2 +2 9 5 6 +11 9 +10 50 3 11 +43 44 74 98 62 60 99 4 11 73 +4 8 8 49 +68 58 82 73 +7 1 4 66 +18 66 39 83 48 99 79 +9 1 1 13 +26 23 84 6 60 87 40 41 25 +6 13 3 28 +30 70 85 13 1 55 diff --git a/contests/Round888/A/main_output0.txt b/contests/Round888/A/main_output0.txt new file mode 100644 index 0000000..5242cc3 --- /dev/null +++ b/contests/Round888/A/main_output0.txt @@ -0,0 +1,7 @@ +2 +1 +4 +1 +0 +0 +3 diff --git a/contests/Round888/B/main b/contests/Round888/B/main new file mode 100755 index 0000000..57a9800 Binary files /dev/null and b/contests/Round888/B/main differ diff --git a/contests/Round888/B/main.cpp b/contests/Round888/B/main.cpp new file mode 100755 index 0000000..ef49c02 --- /dev/null +++ b/contests/Round888/B/main.cpp @@ -0,0 +1,146 @@ +#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); + map mp; + for (int i = 0; i < n; i++) { + cin >> v[i]; + mp[i] = (v[i] % 2 == 0); + } + sort(all(v)); + for (int i = 0; i < n; i++) { + if (mp[i] != (v[i] % 2 == 0)) { + cout << "NO\n"; + return; + } + } + cout << "YES\n"; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round888/B/main_input0.txt b/contests/Round888/B/main_input0.txt new file mode 100644 index 0000000..d92c8a4 --- /dev/null +++ b/contests/Round888/B/main_input0.txt @@ -0,0 +1,13 @@ +6 +5 +7 10 1 3 2 +4 +11 9 3 5 +5 +11 3 15 3 2 +6 +10 7 8 1 2 3 +1 +10 +5 +6 6 4 1 6 diff --git a/contests/Round888/B/main_output0.txt b/contests/Round888/B/main_output0.txt new file mode 100644 index 0000000..f47b8ff --- /dev/null +++ b/contests/Round888/B/main_output0.txt @@ -0,0 +1,6 @@ +YES +YES +NO +NO +YES +NO diff --git a/contests/Round888/C/main b/contests/Round888/C/main new file mode 100755 index 0000000..acd2636 Binary files /dev/null and b/contests/Round888/C/main differ diff --git a/contests/Round888/C/main.cpp b/contests/Round888/C/main.cpp new file mode 100755 index 0000000..73f6cf8 --- /dev/null +++ b/contests/Round888/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 + */ + +void solve() { + int n, k; + cin >> n >> k; + vi v(n); + vi fq(n + 1); + for (auto &x : v) { + cin >> x; + fq[x]++; + } + if (v[0] == v[n - 1] && fq[v[0]] >= k) { + cout << "YES\n"; + return; + } + int last_occ_f = -1; + int last_occ_l = -1; + int cnt_f = k; + int cnt_l = k; + for (int i = 0; i < n; i++) { + if (v[i] == v[0] && cnt_f != 0) { + last_occ_f = i; + cnt_f--; + } + } + for (int i = n - 1; i > 0; i--) { + if (v[i] == v[n - 1] && cnt_l != 0) { + last_occ_l = i; + cnt_l--; + } + } + if (fq[v.front()] >= k && fq[v.back()] >= k && last_occ_f < last_occ_l) { + 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/Round888/C/main_input0.txt b/contests/Round888/C/main_input0.txt new file mode 100644 index 0000000..5ab5138 --- /dev/null +++ b/contests/Round888/C/main_input0.txt @@ -0,0 +1,21 @@ +10 +4 2 +1 1 1 1 +14 3 +1 2 1 1 7 5 3 3 1 3 4 4 2 4 +3 3 +3 1 3 +10 4 +1 2 1 2 1 2 1 2 1 2 +6 2 +1 3 4 1 6 6 +2 2 +1 1 +4 2 +2 1 1 1 +2 1 +1 2 +3 2 +2 2 2 +4 1 +1 1 2 2 diff --git a/contests/Round888/C/main_input1.txt b/contests/Round888/C/main_input1.txt new file mode 100644 index 0000000..79cc46c --- /dev/null +++ b/contests/Round888/C/main_input1.txt @@ -0,0 +1,3 @@ +1 +14 3 +1 2 1 1 7 5 3 3 1 3 4 4 2 4 \ No newline at end of file diff --git a/contests/Round888/C/main_input2.txt b/contests/Round888/C/main_input2.txt new file mode 100644 index 0000000..5042551 --- /dev/null +++ b/contests/Round888/C/main_input2.txt @@ -0,0 +1,3 @@ +1 +8 2 +1 1 6 1 5 5 6 6 \ No newline at end of file diff --git a/contests/Round888/C/main_output0.txt b/contests/Round888/C/main_output0.txt new file mode 100644 index 0000000..030f178 --- /dev/null +++ b/contests/Round888/C/main_output0.txt @@ -0,0 +1,10 @@ +YES +YES +NO +NO +YES +YES +NO +YES +YES +YES diff --git a/contests/Round888/C/main_output1.txt b/contests/Round888/C/main_output1.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/contests/Round888/C/main_output1.txt @@ -0,0 +1 @@ +YES \ No newline at end of file diff --git a/contests/Round888/C/main_output2.txt b/contests/Round888/C/main_output2.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/contests/Round888/C/main_output2.txt @@ -0,0 +1 @@ +YES \ No newline at end of file diff --git a/contests/Round888/D/main b/contests/Round888/D/main new file mode 100755 index 0000000..164e785 Binary files /dev/null and b/contests/Round888/D/main differ diff --git a/contests/Round888/D/main.cpp b/contests/Round888/D/main.cpp new file mode 100755 index 0000000..df3eb45 --- /dev/null +++ b/contests/Round888/D/main.cpp @@ -0,0 +1,145 @@ +#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; + n--; + vll v(n); + vll diff(n); + for (int i = 0; i < n; i++) { + cin >> v[i]; + } + diff[0] = v[0]; + for (int i = 1; i < n; i++) { + diff[i] = v[i] - v[i - 1]; + } + for (int i = 0; i < n; i++) { + } + dbg(diff); +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round888/D/main_input0.txt b/contests/Round888/D/main_input0.txt new file mode 100644 index 0000000..4856c58 --- /dev/null +++ b/contests/Round888/D/main_input0.txt @@ -0,0 +1,25 @@ +12 +5 +6 8 12 15 +5 +1 6 8 15 +4 +1 2 100 +4 +1 3 6 +2 +2 +3 +1 2 +4 +3 7 10 +5 +5 44 46 50 +4 +1 9 10 +5 +13 21 36 42 +5 +1 2 3 1000000000000000000 +9 +9 11 12 20 25 28 30 33 diff --git a/contests/Round888/D/main_output0.txt b/contests/Round888/D/main_output0.txt new file mode 100644 index 0000000..0679773 --- /dev/null +++ b/contests/Round888/D/main_output0.txt @@ -0,0 +1,12 @@ +YES +YES +NO +YES +YES +NO +YES +NO +NO +NO +NO +NO -- cgit v1.2.3