From 6b548332bfc6469756526002971c422f43f86d0a Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Mon, 24 Jul 2023 13:11:33 +0300 Subject: Removed some empty *.cpp files and Solved some new problems --- codeforces/BearAndBigBrother/main | Bin 0 -> 17832 bytes codeforces/BearAndBigBrother/main.cpp | 136 ++++++++++++++++++++ codeforces/BearAndBigBrother/main_input0.txt | 1 + codeforces/BearAndBigBrother/main_input1.txt | 1 + codeforces/BearAndBigBrother/main_input2.txt | 1 + codeforces/BearAndBigBrother/main_output0.txt | 1 + codeforces/BearAndBigBrother/main_output1.txt | 1 + codeforces/BearAndBigBrother/main_output2.txt | 1 + codeforces/BlankSpace/main | Bin 0 -> 20360 bytes codeforces/BlankSpace/main.cpp | 147 ++++++++++++++++++++++ codeforces/BlankSpace/main_input0.txt | 11 ++ codeforces/BlankSpace/main_output0.txt | 5 + codeforces/GameWithBoard/main | Bin 0 -> 16376 bytes codeforces/GameWithBoard/main.cpp | 137 +++++++++++++++++++++ codeforces/GameWithBoard/main_input0.txt | 3 + codeforces/GameWithBoard/main_output0.txt | 2 + codeforces/GoldRush/main | Bin 0 -> 16376 bytes codeforces/GoldRush/main.cpp | 139 +++++++++++++++++++++ codeforces/GoldRush/main_input0.txt | 12 ++ codeforces/GoldRush/main_output0.txt | 11 ++ codeforces/InsertDigit/main | Bin 0 -> 25848 bytes codeforces/InsertDigit/main.cpp | 148 ++++++++++++++++++++++ codeforces/InsertDigit/main_input0.txt | 23 ++++ codeforces/InsertDigit/main_output0.txt | 11 ++ codeforces/KeepItBeautiful/main | Bin 0 -> 43296 bytes codeforces/KeepItBeautiful/main.cpp | 156 +++++++++++++++++++++++ codeforces/KeepItBeautiful/main_input0.txt | 7 ++ codeforces/KeepItBeautiful/main_output0.txt | 3 + codeforces/LoveStory/main | Bin 0 -> 24064 bytes codeforces/LoveStory/main.cpp | 138 +++++++++++++++++++++ codeforces/LoveStory/main_input0.txt | 6 + codeforces/LoveStory/main_output0.txt | 5 + codeforces/Matching/main | Bin 0 -> 19504 bytes codeforces/Matching/main.cpp | 149 ++++++++++++++++++++++ codeforces/Matching/main_input0.txt | 9 ++ codeforces/Matching/main_input1.txt | 2 + codeforces/Matching/main_output0.txt | 8 ++ codeforces/Matching/main_output1.txt | 1 + codeforces/MrPerfectlFine/main | Bin 0 -> 17288 bytes codeforces/MrPerfectlFine/main.cpp | 150 ++++++++++++++++++++++ codeforces/MrPerfectlFine/main_input0.txt | 30 +++++ codeforces/MrPerfectlFine/main_output0.txt | 6 + codeforces/SortTheSubarray/main | Bin 0 -> 33136 bytes codeforces/SortTheSubarray/main.cpp | 171 ++++++++++++++++++++++++++ codeforces/SortTheSubarray/main_input0.txt | 10 ++ codeforces/SortTheSubarray/main_output0.txt | 3 + codeforces/Tram/main | Bin 27800 -> 22664 bytes codeforces/Tram/main.cpp | 11 +- codeforces/TubeTubeFeed/main.rs | 51 ++++++++ codeforces/TubeTubeFeed/rust-project.json | 16 +++ codeforces/TwoGroups/main.cpp | 16 +-- codeforces/TwoTowers/main.cpp | 30 ++--- codeforces/XorAverage/main.cpp | 39 +++--- codeforces/Yes-Yes/main.cpp | 85 +++++++------ codeforces/YoungPhysicist/YoungPhysicist.cpp | 15 ++- 55 files changed, 1800 insertions(+), 108 deletions(-) create mode 100755 codeforces/BearAndBigBrother/main create mode 100755 codeforces/BearAndBigBrother/main.cpp create mode 100644 codeforces/BearAndBigBrother/main_input0.txt create mode 100644 codeforces/BearAndBigBrother/main_input1.txt create mode 100644 codeforces/BearAndBigBrother/main_input2.txt create mode 100644 codeforces/BearAndBigBrother/main_output0.txt create mode 100644 codeforces/BearAndBigBrother/main_output1.txt create mode 100644 codeforces/BearAndBigBrother/main_output2.txt create mode 100755 codeforces/BlankSpace/main create mode 100755 codeforces/BlankSpace/main.cpp create mode 100644 codeforces/BlankSpace/main_input0.txt create mode 100644 codeforces/BlankSpace/main_output0.txt create mode 100755 codeforces/GameWithBoard/main create mode 100755 codeforces/GameWithBoard/main.cpp create mode 100644 codeforces/GameWithBoard/main_input0.txt create mode 100644 codeforces/GameWithBoard/main_output0.txt create mode 100755 codeforces/GoldRush/main create mode 100755 codeforces/GoldRush/main.cpp create mode 100644 codeforces/GoldRush/main_input0.txt create mode 100644 codeforces/GoldRush/main_output0.txt create mode 100755 codeforces/InsertDigit/main create mode 100755 codeforces/InsertDigit/main.cpp create mode 100644 codeforces/InsertDigit/main_input0.txt create mode 100644 codeforces/InsertDigit/main_output0.txt create mode 100755 codeforces/KeepItBeautiful/main create mode 100755 codeforces/KeepItBeautiful/main.cpp create mode 100644 codeforces/KeepItBeautiful/main_input0.txt create mode 100644 codeforces/KeepItBeautiful/main_output0.txt create mode 100755 codeforces/LoveStory/main create mode 100755 codeforces/LoveStory/main.cpp create mode 100644 codeforces/LoveStory/main_input0.txt create mode 100644 codeforces/LoveStory/main_output0.txt create mode 100755 codeforces/Matching/main create mode 100755 codeforces/Matching/main.cpp create mode 100644 codeforces/Matching/main_input0.txt create mode 100644 codeforces/Matching/main_input1.txt create mode 100644 codeforces/Matching/main_output0.txt create mode 100644 codeforces/Matching/main_output1.txt create mode 100755 codeforces/MrPerfectlFine/main create mode 100755 codeforces/MrPerfectlFine/main.cpp create mode 100644 codeforces/MrPerfectlFine/main_input0.txt create mode 100644 codeforces/MrPerfectlFine/main_output0.txt create mode 100755 codeforces/SortTheSubarray/main create mode 100755 codeforces/SortTheSubarray/main.cpp create mode 100644 codeforces/SortTheSubarray/main_input0.txt create mode 100644 codeforces/SortTheSubarray/main_output0.txt create mode 100644 codeforces/TubeTubeFeed/main.rs create mode 100644 codeforces/TubeTubeFeed/rust-project.json (limited to 'codeforces') diff --git a/codeforces/BearAndBigBrother/main b/codeforces/BearAndBigBrother/main new file mode 100755 index 0000000..0098166 Binary files /dev/null and b/codeforces/BearAndBigBrother/main differ diff --git a/codeforces/BearAndBigBrother/main.cpp b/codeforces/BearAndBigBrother/main.cpp new file mode 100755 index 0000000..d4e9c1f --- /dev/null +++ b/codeforces/BearAndBigBrother/main.cpp @@ -0,0 +1,136 @@ +#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 print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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 a, b; + cin >> a >> b; + int ans = 0; + while (a <= b) { + a *= 3; + b *= 2; + ans++; + } + cout << ans << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + solve(); +} + + diff --git a/codeforces/BearAndBigBrother/main_input0.txt b/codeforces/BearAndBigBrother/main_input0.txt new file mode 100644 index 0000000..9ac1165 --- /dev/null +++ b/codeforces/BearAndBigBrother/main_input0.txt @@ -0,0 +1 @@ +4 7 diff --git a/codeforces/BearAndBigBrother/main_input1.txt b/codeforces/BearAndBigBrother/main_input1.txt new file mode 100644 index 0000000..aaf5572 --- /dev/null +++ b/codeforces/BearAndBigBrother/main_input1.txt @@ -0,0 +1 @@ +4 9 diff --git a/codeforces/BearAndBigBrother/main_input2.txt b/codeforces/BearAndBigBrother/main_input2.txt new file mode 100644 index 0000000..2fb73a0 --- /dev/null +++ b/codeforces/BearAndBigBrother/main_input2.txt @@ -0,0 +1 @@ +1 1 diff --git a/codeforces/BearAndBigBrother/main_output0.txt b/codeforces/BearAndBigBrother/main_output0.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/codeforces/BearAndBigBrother/main_output0.txt @@ -0,0 +1 @@ +2 diff --git a/codeforces/BearAndBigBrother/main_output1.txt b/codeforces/BearAndBigBrother/main_output1.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/BearAndBigBrother/main_output1.txt @@ -0,0 +1 @@ +3 diff --git a/codeforces/BearAndBigBrother/main_output2.txt b/codeforces/BearAndBigBrother/main_output2.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/codeforces/BearAndBigBrother/main_output2.txt @@ -0,0 +1 @@ +1 diff --git a/codeforces/BlankSpace/main b/codeforces/BlankSpace/main new file mode 100755 index 0000000..4d5ec29 Binary files /dev/null and b/codeforces/BlankSpace/main differ diff --git a/codeforces/BlankSpace/main.cpp b/codeforces/BlankSpace/main.cpp new file mode 100755 index 0000000..cfbe4e3 --- /dev/null +++ b/codeforces/BlankSpace/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; + vi v(n); + for (auto &x : v) + cin >> x; + int ans = 0; + for (int i = 0; i < n; i++) { + if (v[i] == 0) { + int cnt = 0; + while (v[i] == 0 && i < n) { + cnt++; + i++; + } + ans = max(ans, cnt); + } + } + cout << ans << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/BlankSpace/main_input0.txt b/codeforces/BlankSpace/main_input0.txt new file mode 100644 index 0000000..6eaba88 --- /dev/null +++ b/codeforces/BlankSpace/main_input0.txt @@ -0,0 +1,11 @@ +5 +5 +1 0 0 1 0 +4 +0 1 1 1 +1 +0 +3 +1 1 1 +9 +1 0 0 0 1 0 0 0 1 diff --git a/codeforces/BlankSpace/main_output0.txt b/codeforces/BlankSpace/main_output0.txt new file mode 100644 index 0000000..1d18ba1 --- /dev/null +++ b/codeforces/BlankSpace/main_output0.txt @@ -0,0 +1,5 @@ +2 +1 +1 +0 +3 diff --git a/codeforces/GameWithBoard/main b/codeforces/GameWithBoard/main new file mode 100755 index 0000000..20d57ba Binary files /dev/null and b/codeforces/GameWithBoard/main differ diff --git a/codeforces/GameWithBoard/main.cpp b/codeforces/GameWithBoard/main.cpp new file mode 100755 index 0000000..f9df6d0 --- /dev/null +++ b/codeforces/GameWithBoard/main.cpp @@ -0,0 +1,137 @@ +#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; + if (n <= 4) { + cout << "Bob\n"; + } else { + cout << "Alice\n"; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/GameWithBoard/main_input0.txt b/codeforces/GameWithBoard/main_input0.txt new file mode 100644 index 0000000..a178d04 --- /dev/null +++ b/codeforces/GameWithBoard/main_input0.txt @@ -0,0 +1,3 @@ +2 +3 +6 diff --git a/codeforces/GameWithBoard/main_output0.txt b/codeforces/GameWithBoard/main_output0.txt new file mode 100644 index 0000000..45531b2 --- /dev/null +++ b/codeforces/GameWithBoard/main_output0.txt @@ -0,0 +1,2 @@ +Bob +Alice diff --git a/codeforces/GoldRush/main b/codeforces/GoldRush/main new file mode 100755 index 0000000..dbaf809 Binary files /dev/null and b/codeforces/GoldRush/main differ diff --git a/codeforces/GoldRush/main.cpp b/codeforces/GoldRush/main.cpp new file mode 100755 index 0000000..a6de3d9 --- /dev/null +++ b/codeforces/GoldRush/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, s; + cin >> n >> s; + if (n > s && n % 3 == 0) { + while (n != 1) { + } + 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/codeforces/GoldRush/main_input0.txt b/codeforces/GoldRush/main_input0.txt new file mode 100644 index 0000000..61f3631 --- /dev/null +++ b/codeforces/GoldRush/main_input0.txt @@ -0,0 +1,12 @@ +11 +6 4 +9 4 +4 2 +18 27 +27 4 +27 2 +27 10 +1 1 +3 1 +5 1 +746001 2984004 diff --git a/codeforces/GoldRush/main_output0.txt b/codeforces/GoldRush/main_output0.txt new file mode 100644 index 0000000..d99d5ba --- /dev/null +++ b/codeforces/GoldRush/main_output0.txt @@ -0,0 +1,11 @@ +YES +YES +NO +NO +YES +YES +NO +YES +YES +NO +NO diff --git a/codeforces/InsertDigit/main b/codeforces/InsertDigit/main new file mode 100755 index 0000000..0e3aff8 Binary files /dev/null and b/codeforces/InsertDigit/main differ diff --git a/codeforces/InsertDigit/main.cpp b/codeforces/InsertDigit/main.cpp new file mode 100755 index 0000000..43270a6 --- /dev/null +++ b/codeforces/InsertDigit/main.cpp @@ -0,0 +1,148 @@ +#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 print() { + cerr << "\n"; +} + +template +void print(T val, TS... vals) { + cerr << val << " "; + print(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, d; + cin >> n >> d; + string s; + cin >> s; + string ans = ""; + bool flag = 0; + for (int i = 0; i < n; i++) { + if (s[i] - '0' < d && !flag) { + ans += d + '0'; + flag = 1; + } + ans += s[i]; + } + if (ans.size() != n + 1) { + ans += d + '0'; + } + cout << ans << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + + diff --git a/codeforces/InsertDigit/main_input0.txt b/codeforces/InsertDigit/main_input0.txt new file mode 100644 index 0000000..b32fe58 --- /dev/null +++ b/codeforces/InsertDigit/main_input0.txt @@ -0,0 +1,23 @@ +11 +5 4 +76543 +1 0 +1 +2 5 +44 +3 6 +666 +5 6 +13579 +5 8 +97531 +19 4 +9876543210123456789 +5 7 +73737 +8 1 +20000000 +7 0 +7058959 +12 1 +828127127732 diff --git a/codeforces/InsertDigit/main_output0.txt b/codeforces/InsertDigit/main_output0.txt new file mode 100644 index 0000000..540ec1c --- /dev/null +++ b/codeforces/InsertDigit/main_output0.txt @@ -0,0 +1,11 @@ +765443 +10 +544 +6666 +613579 +987531 +98765443210123456789 +773737 +210000000 +70589590 +8281271277321 diff --git a/codeforces/KeepItBeautiful/main b/codeforces/KeepItBeautiful/main new file mode 100755 index 0000000..80ce9ad Binary files /dev/null and b/codeforces/KeepItBeautiful/main differ diff --git a/codeforces/KeepItBeautiful/main.cpp b/codeforces/KeepItBeautiful/main.cpp new file mode 100755 index 0000000..9be7954 --- /dev/null +++ b/codeforces/KeepItBeautiful/main.cpp @@ -0,0 +1,156 @@ +#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 q; + cin >> q; + const int inf = 1e9; + int lst = -inf; + int drop = false; + string ans = ""; + while (q--) { + int x; + cin >> x; + if (x >= lst) { + if (drop) { + + } else { + ans += "1"; + } + } else { + if (drop) { + ans += "0"; + } else { + ans += "1"; + lst = x; + drop = true; + } + } + } + cout << ans << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/KeepItBeautiful/main_input0.txt b/codeforces/KeepItBeautiful/main_input0.txt new file mode 100644 index 0000000..cb1c3e9 --- /dev/null +++ b/codeforces/KeepItBeautiful/main_input0.txt @@ -0,0 +1,7 @@ +3 +9 +3 7 7 9 2 4 6 3 4 +5 +1 1 1 1 1 +5 +3 2 1 2 3 diff --git a/codeforces/KeepItBeautiful/main_output0.txt b/codeforces/KeepItBeautiful/main_output0.txt new file mode 100644 index 0000000..23f25a7 --- /dev/null +++ b/codeforces/KeepItBeautiful/main_output0.txt @@ -0,0 +1,3 @@ +111110010 +11111 +11011 diff --git a/codeforces/LoveStory/main b/codeforces/LoveStory/main new file mode 100755 index 0000000..c3ad247 Binary files /dev/null and b/codeforces/LoveStory/main differ diff --git a/codeforces/LoveStory/main.cpp b/codeforces/LoveStory/main.cpp new file mode 100755 index 0000000..6ffcab9 --- /dev/null +++ b/codeforces/LoveStory/main.cpp @@ -0,0 +1,138 @@ +#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 cmp = "codeforces"; + int ans = 0; + for (int i = 0; i < s.length(); i++) { + ans += cmp[i] != s[i]; + } + cout << ans << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/LoveStory/main_input0.txt b/codeforces/LoveStory/main_input0.txt new file mode 100644 index 0000000..211e6b1 --- /dev/null +++ b/codeforces/LoveStory/main_input0.txt @@ -0,0 +1,6 @@ +5 +coolforsez +cadafurcie +codeforces +paiuforces +forcescode diff --git a/codeforces/LoveStory/main_output0.txt b/codeforces/LoveStory/main_output0.txt new file mode 100644 index 0000000..28f59d5 --- /dev/null +++ b/codeforces/LoveStory/main_output0.txt @@ -0,0 +1,5 @@ +4 +5 +0 +4 +9 diff --git a/codeforces/Matching/main b/codeforces/Matching/main new file mode 100755 index 0000000..753c0d7 Binary files /dev/null and b/codeforces/Matching/main differ diff --git a/codeforces/Matching/main.cpp b/codeforces/Matching/main.cpp new file mode 100755 index 0000000..da4156e --- /dev/null +++ b/codeforces/Matching/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() { + string s; + cin >> s; + int qm = 0; + for (auto ch : s) { + qm += ch == '?'; + } + if (s[0] == '0') { + cout << 0 << '\n'; + return; + } + if (qm == 0) { + cout << (s[0] == '0' ? 0 : 1) << '\n'; + } else { + if (s[0] == '?') { + cout << pow(10, qm) - pow(10, qm - 1) << '\n'; + } else { + cout << pow(10, qm) << '\n'; + } + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/Matching/main_input0.txt b/codeforces/Matching/main_input0.txt new file mode 100644 index 0000000..3e37218 --- /dev/null +++ b/codeforces/Matching/main_input0.txt @@ -0,0 +1,9 @@ +8 +?? +? +0 +9 +03 +1??7 +?5? +9??99 diff --git a/codeforces/Matching/main_input1.txt b/codeforces/Matching/main_input1.txt new file mode 100644 index 0000000..c6eed99 --- /dev/null +++ b/codeforces/Matching/main_input1.txt @@ -0,0 +1,2 @@ +1 +0? \ No newline at end of file diff --git a/codeforces/Matching/main_output0.txt b/codeforces/Matching/main_output0.txt new file mode 100644 index 0000000..0a46b00 --- /dev/null +++ b/codeforces/Matching/main_output0.txt @@ -0,0 +1,8 @@ +90 +9 +0 +1 +0 +100 +90 +100 diff --git a/codeforces/Matching/main_output1.txt b/codeforces/Matching/main_output1.txt new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/codeforces/Matching/main_output1.txt @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/codeforces/MrPerfectlFine/main b/codeforces/MrPerfectlFine/main new file mode 100755 index 0000000..d850833 Binary files /dev/null and b/codeforces/MrPerfectlFine/main differ diff --git a/codeforces/MrPerfectlFine/main.cpp b/codeforces/MrPerfectlFine/main.cpp new file mode 100755 index 0000000..5b900f7 --- /dev/null +++ b/codeforces/MrPerfectlFine/main.cpp @@ -0,0 +1,150 @@ +#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 min_f1 = 1e9, min_s1 = 1e9, min_both = 1e9; + for (int i = 0; i < n; i++) { + int book; + string s; + cin >> book >> s; + if (s[0] == '1' && s[1] != '1') { + min_f1 = min(min_f1, book); + } else if (s[1] == '1' && s[0] != '1') { + min_s1 = min(min_s1, book); + } else if (s[0] == '1' && s[1] == '1') { + min_both = min(min_both, book); + } + } + if (min(min_both, min_f1 + min_s1) == 1e9) { + cout << -1 << '\n'; + } else { + cout << min(min_both, min_f1 + min_s1) << '\n'; + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/MrPerfectlFine/main_input0.txt b/codeforces/MrPerfectlFine/main_input0.txt new file mode 100644 index 0000000..f08082c --- /dev/null +++ b/codeforces/MrPerfectlFine/main_input0.txt @@ -0,0 +1,30 @@ +6 +4 +2 00 +3 10 +4 01 +4 00 +5 +3 01 +3 01 +5 01 +2 10 +9 10 +1 +5 11 +3 +9 11 +8 01 +7 10 +6 +4 01 +6 01 +7 01 +8 00 +9 01 +1 00 +4 +8 00 +9 10 +9 11 +8 11 diff --git a/codeforces/MrPerfectlFine/main_output0.txt b/codeforces/MrPerfectlFine/main_output0.txt new file mode 100644 index 0000000..3aaf174 --- /dev/null +++ b/codeforces/MrPerfectlFine/main_output0.txt @@ -0,0 +1,6 @@ +7 +5 +5 +9 +-1 +8 diff --git a/codeforces/SortTheSubarray/main b/codeforces/SortTheSubarray/main new file mode 100755 index 0000000..ede436c Binary files /dev/null and b/codeforces/SortTheSubarray/main differ diff --git a/codeforces/SortTheSubarray/main.cpp b/codeforces/SortTheSubarray/main.cpp new file mode 100755 index 0000000..42d20bb --- /dev/null +++ b/codeforces/SortTheSubarray/main.cpp @@ -0,0 +1,171 @@ +#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 + */ + +std::pair longest_sorted_subarray(std::vector arr) { + int start = 0, end = 0, max_length = 0; + for (int i = 1; i < arr.size(); i++) { + if (arr[i] >= arr[i - 1]) { + end++; + } else { + int length = end - start + 1; + if (length > max_length) { + max_length = length; + start = i - length; + end = i - 1; + } + start = i; + end = i; + } + } + int length = end - start + 1; + if (length > max_length) { + max_length = length; + start = arr.size() - length; + end = arr.size() - 1; + } + if (max_length > 0) { + return {start, end}; + } else { + return {-1, -1}; + } +} + +void solve() { + int n; + cin >> n; + vi a(n); + vi b(n); + for (auto &x : a) { + cin >> x; + } + for (auto &x : b) { + cin >> x; + } + pii ans = longest_sorted_subarray(b); + cout << ans.first + 1 << " " << ans.second + 1 << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/codeforces/SortTheSubarray/main_input0.txt b/codeforces/SortTheSubarray/main_input0.txt new file mode 100644 index 0000000..fbeb308 --- /dev/null +++ b/codeforces/SortTheSubarray/main_input0.txt @@ -0,0 +1,10 @@ +3 +7 +6 7 3 4 4 6 5 +6 3 4 4 7 6 5 +3 +1 2 1 +1 1 2 +3 +2 2 1 +2 1 2 diff --git a/codeforces/SortTheSubarray/main_output0.txt b/codeforces/SortTheSubarray/main_output0.txt new file mode 100644 index 0000000..d54d580 --- /dev/null +++ b/codeforces/SortTheSubarray/main_output0.txt @@ -0,0 +1,3 @@ +2 5 +1 3 +2 3 diff --git a/codeforces/Tram/main b/codeforces/Tram/main index 3c01372..efe2012 100755 Binary files a/codeforces/Tram/main and b/codeforces/Tram/main differ diff --git a/codeforces/Tram/main.cpp b/codeforces/Tram/main.cpp index ff917a6..9b967d3 100755 --- a/codeforces/Tram/main.cpp +++ b/codeforces/Tram/main.cpp @@ -1,4 +1,5 @@ -#include +#include +#include using namespace std; @@ -9,9 +10,9 @@ typedef vector vi; #define INF 1000000000 -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); int mx = 0; int n; cin >> n; @@ -23,6 +24,6 @@ int main () { int x, y; cin >> x >> y; v[i + 1] = v[i] + (y - x); - } + } cout << *max_element(v.begin(), v.end()) << '\n'; } diff --git a/codeforces/TubeTubeFeed/main.rs b/codeforces/TubeTubeFeed/main.rs new file mode 100644 index 0000000..477d31a --- /dev/null +++ b/codeforces/TubeTubeFeed/main.rs @@ -0,0 +1,51 @@ +use std::io; +use std::str::FromStr; + +#[allow(unused_variables)] +#[allow(dead_code)] + +fn read_line() -> String { + let mut buffer = String::new(); + io::stdin() + .read_line(&mut buffer) + .expect("failed to read line"); + + buffer +} + +#[allow(dead_code)] +fn read() -> Result { + read_line().trim().parse::() +} + +#[allow(dead_code)] +fn read_vec() -> Result, T::Err> { + read_line() + .split_whitespace() + .map(|x| x.parse::()) + .collect() +} + +fn solve() { + let v: Vec = read_vec().unwrap(); + let (_, mut t) = (v[0], v[1]); + let a: Vec = read_vec().unwrap(); + let b: Vec = read_vec().unwrap(); + let mut mx = 0; + let mut idx = -1; + for i in 0..a.len() { + if t >= a[i] && b[i] > mx { + idx = i as i32 + 1; + mx = b[i]; + } + t -= 1; + } + println!("{idx}"); +} + +fn main() { + let t = read::().unwrap(); + for _i in 0..t { + solve(); + } +} diff --git a/codeforces/TubeTubeFeed/rust-project.json b/codeforces/TubeTubeFeed/rust-project.json new file mode 100644 index 0000000..9c76ee9 --- /dev/null +++ b/codeforces/TubeTubeFeed/rust-project.json @@ -0,0 +1,16 @@ +{ + "crates": [ + { + "root_module": "main.rs", + "edition": "2021", + "deps": [], + "cfg": [], + "env": {}, + "source": { + "include_dirs": ["."], + "exclude_dirs": [] + } + } + ], + "sysroot_src": "/home/omar/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library" +} diff --git a/codeforces/TwoGroups/main.cpp b/codeforces/TwoGroups/main.cpp index 0f7a8f9..a26bdf0 100755 --- a/codeforces/TwoGroups/main.cpp +++ b/codeforces/TwoGroups/main.cpp @@ -1,13 +1,13 @@ -#include +#include using namespace std; -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--){ +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { int n; cin >> n; long long ans = 0; @@ -17,5 +17,5 @@ int main () { ans += x; } cout << abs(ans) << '\n'; - } + } } diff --git a/codeforces/TwoTowers/main.cpp b/codeforces/TwoTowers/main.cpp index faef146..184a0ad 100755 --- a/codeforces/TwoTowers/main.cpp +++ b/codeforces/TwoTowers/main.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; using ll = long long; @@ -10,7 +10,7 @@ using mpii = map; using mpll = map; using db = long double; -#define pb push_back +#define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define lb lower_bound @@ -23,17 +23,15 @@ const db PI = acos((db)-1); const int dx[4]{1, 0, -1, 0}; const int dy[4]{0, 1, 0, -1}; -//pretty printing -template -void printm(const map &mp) { +// pretty printing +template void printm(const map &mp) { cerr << "{" << endl; for (auto p : mp) { cerr << " { " << p.first << " : " << p.second << " }\n"; } cerr << "}" << endl; } -template -void printv(const vector &v) { +template void printv(const vector &v) { cerr << "["; for (int i = 0; i < v.size(); i++) { if (i == v.size() - 1) { @@ -45,8 +43,7 @@ void printv(const vector &v) { cerr << "]\n"; } -template -void printvv(const vector> &v) { +template void printvv(const vector> &v) { cerr << "[\n"; for (auto &vec : v) { cout << " "; @@ -54,18 +51,13 @@ void printvv(const vector> &v) { } cerr << "]\n"; } -void print() { - cerr << "\n"; -} +void print() { cerr << "\n"; } -template -void print(T val, TS... vals) { +template void print(T val, TS... vals) { cerr << val << " "; print(vals...); } - - /* stuff you should look for: --------------------------- * special cases (n=1?) @@ -100,14 +92,12 @@ void solve() { cout << (cnt <= 1 ? "YES\n" : "NO\n"); } -int main () { +int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tt; cin >> tt; - while(tt--) { + while (tt--) { solve(); } } - - diff --git a/codeforces/XorAverage/main.cpp b/codeforces/XorAverage/main.cpp index 9f3f41a..89e1fcd 100755 --- a/codeforces/XorAverage/main.cpp +++ b/codeforces/XorAverage/main.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; using ll = long long; @@ -10,7 +10,7 @@ using mpii = map; using mpll = map; using db = long double; -#define pb push_back +#define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define lb lower_bound @@ -21,17 +21,15 @@ const db PI = acos((db)-1); const int dx[4]{1, 0, -1, 0}; const int dy[4]{0, 1, 0, -1}; -//pretty printing -template -void printm(const map &mp) { +// pretty printing +template void printm(const map &mp) { cerr << "{" << endl; for (auto p : mp) { cerr << " { " << p.first << " : " << p.second << " }\n"; } cerr << "}" << endl; } -template -void printv(const vector &v) { +template void printv(const vector &v) { cerr << "["; for (int i = 0; i < v.size(); i++) { if (i == v.size() - 1) { @@ -43,8 +41,7 @@ void printv(const vector &v) { cerr << "]\n"; } -template -void printvv(const vector> &v) { +template void printvv(const vector> &v) { cerr << "[\n"; for (auto &vec : v) { cout << " "; @@ -52,17 +49,13 @@ void printvv(const vector> &v) { } cerr << "]\n"; } -void print() { - cerr << "\n"; -} +void print() { cerr << "\n"; } -template -void print(T val, TS... vals) { +template void print(T val, TS... vals) { cerr << val << " "; print(vals...); } - /* stuff you should look for: --------------------------- * special cases (n=1?) @@ -87,14 +80,12 @@ void solve() { } } -int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); - int tt; - cin >> tt; - while(tt--) { +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { solve(); - } + } } - - diff --git a/codeforces/Yes-Yes/main.cpp b/codeforces/Yes-Yes/main.cpp index 0598977..ca84b43 100755 --- a/codeforces/Yes-Yes/main.cpp +++ b/codeforces/Yes-Yes/main.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; using ll = long long; @@ -10,70 +10,75 @@ using mpii = map; using mpll = map; using db = long double; -#define pb push_back +#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 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 int MOD = static_cast(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) { +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) { +template ostream &operator<<(ostream &os, const vector &vec) { os << "{"; for (size_t i = 0; i < vec.size(); ++i) { - if (i > 0) os << ", "; + if (i > 0) + os << ", "; os << vec[i]; } os << "}"; return os; } - -template -ostream& operator<<(ostream& os, const map& m) { +template +ostream &operator<<(ostream &os, const map &m) { os << "{"; - for (const auto& p : m) { + for (const auto &p : m) { os << p.first << ": " << p.second << ", "; } os << "}"; return os; } -template -ostream& operator<<(ostream& os, const unordered_map& m) { +template +ostream &operator<<(ostream &os, const unordered_map &m) { os << "{"; - for (const auto& p : m) { + for (const auto &p : m) { os << p.first << ": " << p.second << ", "; } os << "}"; return os; } -template -ostream& operator<<(ostream& os, const set& s) { +template ostream &operator<<(ostream &os, const set &s) { int i = 0; os << "{"; - for (const auto& e : s) { - if (i > 0) os << ", "; + for (const auto &e : s) { + if (i > 0) + os << ", "; os << e; i++; } @@ -81,12 +86,13 @@ ostream& operator<<(ostream& os, const set& s) { return os; } -template -ostream& operator<<(ostream& os, const unordered_set& s) { +template +ostream &operator<<(ostream &os, const unordered_set &s) { int i = 0; os << "{"; - for (const auto& e : s) { - if (i > 0) os << ", "; + for (const auto &e : s) { + if (i > 0) + os << ", "; os << e; i++; } @@ -94,18 +100,13 @@ ostream& operator<<(ostream& os, const unordered_set& s) { return os; } -void print() { - cerr << "\n"; -} +void print() { cerr << "\n"; } -template -void print(T val, TS... vals) { +template void print(T val, TS... vals) { cerr << val << " "; print(vals...); } - - /* stuff you should look for: --------------------------- * special cases (n=1?) @@ -121,7 +122,7 @@ void solve() { int n = s.size(); string yes = "Yes"; int pos = yes.find(s[0]); - if (pos == string:: npos) { + if (pos == string::npos) { cout << "NO\n"; return; } @@ -135,14 +136,12 @@ void solve() { cout << "YES\n"; } -int main () { +int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tt; cin >> tt; - while(tt--) { + while (tt--) { solve(); } } - - diff --git a/codeforces/YoungPhysicist/YoungPhysicist.cpp b/codeforces/YoungPhysicist/YoungPhysicist.cpp index b126bd1..dc5056b 100755 --- a/codeforces/YoungPhysicist/YoungPhysicist.cpp +++ b/codeforces/YoungPhysicist/YoungPhysicist.cpp @@ -1,22 +1,21 @@ -#include +#include using namespace std; int main() { int n; cin >> n; vector> v(n); - for(int i = 0; i < n; i++) { - for(int j = 0; j < 3; j++) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < 3; j++) { int x; cin >> x; v[i].push_back(x); } } int x = 0, y = 0, z = 0; - for(int i = 0; i < n; i++) { - x+=v[i][0]; - y+=v[i][1]