From 95422138588572e08a1ee78e654741874f11cfa0 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Thu, 10 Nov 2022 16:05:26 +0200 Subject: Added some new problems --- UVA/Introduction/RelationalOperators/main.cpp | 28 ++++++ UVA/Introduction/TheSnail/main.cpp | 23 +++++ UVA/PIDigits/main | Bin 0 -> 22696 bytes UVA/PIDigits/main.cpp | 20 ++++ UVA/PIDigits/main_input0.txt | 1 + UVA/PIDigits/main_input1.txt | 1 + UVA/PIDigits/main_output0.txt | 1 + UVA/PIDigits/main_output1.txt | 1 + codeforces/BanBan/main | Bin 0 -> 26952 bytes codeforces/BanBan/main.cpp | 32 +++++++ codeforces/BanBan/main_input0.txt | 3 + codeforces/BanBan/main_input1.txt | 101 +++++++++++++++++++++ codeforces/BanBan/main_output0.txt | 4 + codeforces/BanBan/main_output1.txt | 2 + codeforces/CowardlyRooks/main | Bin 0 -> 67656 bytes codeforces/CowardlyRooks/main.cpp | 77 ++++++++++++++++ codeforces/CowardlyRooks/main_input0.txt | 6 ++ codeforces/CowardlyRooks/main_input1.txt | 6 ++ codeforces/CowardlyRooks/main_output0.txt | 2 + codeforces/CowardlyRooks/main_output1.txt | 1 + codeforces/Cupboards/main | Bin 0 -> 22584 bytes codeforces/Cupboards/main.cpp | 33 +++++++ codeforces/Cupboards/main_input0.txt | 6 ++ codeforces/Cupboards/main_output0.txt | 1 + codeforces/ILove%username/main | Bin 0 -> 26784 bytes codeforces/ILove%username/main.cpp | 32 +++++++ codeforces/ILove%username/main_input0.txt | 2 + codeforces/ILove%username/main_input1.txt | 2 + codeforces/ILove%username/main_output0.txt | 1 + codeforces/ILove%username/main_output1.txt | 1 + codeforces/Tram/main | Bin 0 -> 27800 bytes codeforces/Tram/main.cpp | 28 ++++++ codeforces/Tram/main_input0.txt | 5 + codeforces/Tram/main_output0.txt | 1 + codeforces/TwoGroups/main | Bin 0 -> 22576 bytes codeforces/TwoGroups/main.cpp | 21 +++++ codeforces/TwoGroups/main_input0.txt | 9 ++ codeforces/TwoGroups/main_output0.txt | 4 + contests/Round#828/A/main | Bin 0 -> 59888 bytes contests/Round#828/A/main.cpp | 39 ++++++++ contests/Round#828/B/main | Bin 0 -> 26712 bytes contests/Round#828/B/main.cpp | 48 ++++++++++ contests/Round#828/B/main_input0.txt | 27 ++++++ contests/Round#828/B/main_output0.txt | 18 ++++ contests/Round#828/C/main | Bin 0 -> 51696 bytes contests/Round#828/C/main.cpp | 48 ++++++++++ contests/Round#828/C/main_input0.txt | 13 +++ contests/Round#828/C/main_output0.txt | 6 ++ contests/Round#828/D/main.cpp | 20 ++++ contests/Round#828/E/main.cpp | 20 ++++ contests/Round#828/F/main.cpp | 20 ++++ contests/filtrationContest/C/main | Bin 22528 -> 50432 bytes contests/filtrationContest/C/main.cpp | 26 +++--- cses/SortingAndSearching/Apartments/main | Bin 0 -> 63000 bytes cses/SortingAndSearching/Apartments/main.cpp | 25 +++-- .../SortingAndSearching/Apartments/main_input0.txt | 3 + .../Apartments/main_output0.txt | 1 + cses/SortingAndSearching/FerrisWheel/main | Bin 0 -> 44536 bytes cses/SortingAndSearching/FerrisWheel/main.cpp | 34 +++++++ .../FerrisWheel/main_input0.txt | 2 + .../FerrisWheel/main_input1.txt | 1 + .../FerrisWheel/main_input2.txt | 2 + .../FerrisWheel/main_input3.txt | 2 + .../FerrisWheel/main_output0.txt | 1 + .../FerrisWheel/main_output1.txt | 1 + .../FerrisWheel/main_output2.txt | 1 + .../FerrisWheel/main_output3.txt | 1 + 67 files changed, 790 insertions(+), 24 deletions(-) create mode 100644 UVA/Introduction/RelationalOperators/main.cpp create mode 100644 UVA/Introduction/TheSnail/main.cpp create mode 100755 UVA/PIDigits/main create mode 100644 UVA/PIDigits/main.cpp create mode 100644 UVA/PIDigits/main_input0.txt create mode 100644 UVA/PIDigits/main_input1.txt create mode 100644 UVA/PIDigits/main_output0.txt create mode 100644 UVA/PIDigits/main_output1.txt create mode 100755 codeforces/BanBan/main create mode 100644 codeforces/BanBan/main.cpp create mode 100644 codeforces/BanBan/main_input0.txt create mode 100644 codeforces/BanBan/main_input1.txt create mode 100644 codeforces/BanBan/main_output0.txt create mode 100644 codeforces/BanBan/main_output1.txt create mode 100755 codeforces/CowardlyRooks/main create mode 100644 codeforces/CowardlyRooks/main.cpp create mode 100644 codeforces/CowardlyRooks/main_input0.txt create mode 100644 codeforces/CowardlyRooks/main_input1.txt create mode 100644 codeforces/CowardlyRooks/main_output0.txt create mode 100644 codeforces/CowardlyRooks/main_output1.txt create mode 100755 codeforces/Cupboards/main create mode 100644 codeforces/Cupboards/main.cpp create mode 100644 codeforces/Cupboards/main_input0.txt create mode 100644 codeforces/Cupboards/main_output0.txt create mode 100755 codeforces/ILove%username/main create mode 100644 codeforces/ILove%username/main.cpp create mode 100644 codeforces/ILove%username/main_input0.txt create mode 100644 codeforces/ILove%username/main_input1.txt create mode 100644 codeforces/ILove%username/main_output0.txt create mode 100644 codeforces/ILove%username/main_output1.txt create mode 100755 codeforces/Tram/main create mode 100644 codeforces/Tram/main.cpp create mode 100644 codeforces/Tram/main_input0.txt create mode 100644 codeforces/Tram/main_output0.txt create mode 100755 codeforces/TwoGroups/main create mode 100644 codeforces/TwoGroups/main.cpp create mode 100644 codeforces/TwoGroups/main_input0.txt create mode 100644 codeforces/TwoGroups/main_output0.txt create mode 100755 contests/Round#828/A/main create mode 100644 contests/Round#828/A/main.cpp create mode 100755 contests/Round#828/B/main create mode 100644 contests/Round#828/B/main.cpp create mode 100644 contests/Round#828/B/main_input0.txt create mode 100644 contests/Round#828/B/main_output0.txt create mode 100755 contests/Round#828/C/main create mode 100644 contests/Round#828/C/main.cpp create mode 100644 contests/Round#828/C/main_input0.txt create mode 100644 contests/Round#828/C/main_output0.txt create mode 100644 contests/Round#828/D/main.cpp create mode 100644 contests/Round#828/E/main.cpp create mode 100644 contests/Round#828/F/main.cpp create mode 100755 cses/SortingAndSearching/Apartments/main create mode 100644 cses/SortingAndSearching/Apartments/main_input0.txt create mode 100644 cses/SortingAndSearching/Apartments/main_output0.txt create mode 100755 cses/SortingAndSearching/FerrisWheel/main create mode 100644 cses/SortingAndSearching/FerrisWheel/main.cpp create mode 100644 cses/SortingAndSearching/FerrisWheel/main_input0.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_input1.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_input2.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_input3.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_output0.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_output1.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_output2.txt create mode 100644 cses/SortingAndSearching/FerrisWheel/main_output3.txt diff --git a/UVA/Introduction/RelationalOperators/main.cpp b/UVA/Introduction/RelationalOperators/main.cpp new file mode 100644 index 0000000..6f03abd --- /dev/null +++ b/UVA/Introduction/RelationalOperators/main.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + int n, m; + cin >> n >> m; + if (n < m) { + cout << "<" << '\n'; + } else if (n > m) { + cout << ">" << '\n'; + } else { + cout << "=" << '\n'; + } + } +} diff --git a/UVA/Introduction/TheSnail/main.cpp b/UVA/Introduction/TheSnail/main.cpp new file mode 100644 index 0000000..bdc2bf0 --- /dev/null +++ b/UVA/Introduction/TheSnail/main.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int h, u, d, f, i = 1; + while(cin >> h >> u >> d >> f) { + vi v(100); + v[i] = h - + + + + } +} diff --git a/UVA/PIDigits/main b/UVA/PIDigits/main new file mode 100755 index 0000000..f8a3206 Binary files /dev/null and b/UVA/PIDigits/main differ diff --git a/UVA/PIDigits/main.cpp b/UVA/PIDigits/main.cpp new file mode 100644 index 0000000..511c72a --- /dev/null +++ b/UVA/PIDigits/main.cpp @@ -0,0 +1,20 @@ +#include +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + double PI = acos(-1); + cout << setprecision(n + 1) << PI << '\n'; +} diff --git a/UVA/PIDigits/main_input0.txt b/UVA/PIDigits/main_input0.txt new file mode 100644 index 0000000..7813681 --- /dev/null +++ b/UVA/PIDigits/main_input0.txt @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/UVA/PIDigits/main_input1.txt b/UVA/PIDigits/main_input1.txt new file mode 100644 index 0000000..3f10ffe --- /dev/null +++ b/UVA/PIDigits/main_input1.txt @@ -0,0 +1 @@ +15 \ No newline at end of file diff --git a/UVA/PIDigits/main_output0.txt b/UVA/PIDigits/main_output0.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/UVA/PIDigits/main_output0.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/UVA/PIDigits/main_output1.txt b/UVA/PIDigits/main_output1.txt new file mode 100644 index 0000000..9bd2462 --- /dev/null +++ b/UVA/PIDigits/main_output1.txt @@ -0,0 +1 @@ +3.1415923452129312 \ No newline at end of file diff --git a/codeforces/BanBan/main b/codeforces/BanBan/main new file mode 100755 index 0000000..2102f9d Binary files /dev/null and b/codeforces/BanBan/main differ diff --git a/codeforces/BanBan/main.cpp b/codeforces/BanBan/main.cpp new file mode 100644 index 0000000..abe1f05 --- /dev/null +++ b/codeforces/BanBan/main.cpp @@ -0,0 +1,32 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + if (n == 1) { + cout << n << '\n' << 1 << " " << 2 << '\n'; + } else { + cout << n - 1 << '\n'; + vector v(n); + int cnt = 0; + for (int i = 0; cnt != n - 1 && i < n; i++) { + if((3 * n - 1 - i) % 3 != 0) { + cerr << (3 * n - 1 - i) << endl; + v[i] = (3 * n - 1 - i); + cnt++; + } + } + // cerr << "n - 1 " << n - 1 << endl; + for (int i = 0; i < n - 1; i++) { + cout << i * 3 + 1 << " " << v[i] + 1 << endl; + } + } + } +} diff --git a/codeforces/BanBan/main_input0.txt b/codeforces/BanBan/main_input0.txt new file mode 100644 index 0000000..5357a4a --- /dev/null +++ b/codeforces/BanBan/main_input0.txt @@ -0,0 +1,3 @@ +2 +1 +2 diff --git a/codeforces/BanBan/main_input1.txt b/codeforces/BanBan/main_input1.txt new file mode 100644 index 0000000..bf3f482 --- /dev/null +++ b/codeforces/BanBan/main_input1.txt @@ -0,0 +1,101 @@ +100 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 \ No newline at end of file diff --git a/codeforces/BanBan/main_output0.txt b/codeforces/BanBan/main_output0.txt new file mode 100644 index 0000000..3edf315 --- /dev/null +++ b/codeforces/BanBan/main_output0.txt @@ -0,0 +1,4 @@ +1 +1 2 +1 +2 6 diff --git a/codeforces/BanBan/main_output1.txt b/codeforces/BanBan/main_output1.txt new file mode 100644 index 0000000..95bce4d --- /dev/null +++ b/codeforces/BanBan/main_output1.txt @@ -0,0 +1,2 @@ +1 +1 2 \ No newline at end of file diff --git a/codeforces/CowardlyRooks/main b/codeforces/CowardlyRooks/main new file mode 100755 index 0000000..9768b26 Binary files /dev/null and b/codeforces/CowardlyRooks/main differ diff --git a/codeforces/CowardlyRooks/main.cpp b/codeforces/CowardlyRooks/main.cpp new file mode 100644 index 0000000..0c1f7e5 --- /dev/null +++ b/codeforces/CowardlyRooks/main.cpp @@ -0,0 +1,77 @@ +#include + +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vvi = 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 + +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}; + +string solve() { + int n, m; + cin >> n >> m; + vector> v(n, vector(n, false)); + vpi points; + for (int i = 0; i < m; i++) { + int x, y; + cin >> x >> y; + points.pb(make_pair(x, y)); + } + for (auto p : points) { + v[p.first - 1][p.second - 1] = 1; + for (auto pp : points) { + if(pp != p) { + for (int i = 0; i < n; i++) { + v[pp.first - 1][i]=1; + cerr << v[pp.first - 1][i] << endl; + } + for (int i = 0; i < n; i++) { + v[i][pp.second - 1] = 1; + } + } + } + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (v[i][j] == 0 && (p.first - 1 == i || p.second - 1 == j)) { + return "YES"; + } + } + } + } + return "NO"; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + cout << solve() << '\n'; + } +} + +/* 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 + */ diff --git a/codeforces/CowardlyRooks/main_input0.txt b/codeforces/CowardlyRooks/main_input0.txt new file mode 100644 index 0000000..d314945 --- /dev/null +++ b/codeforces/CowardlyRooks/main_input0.txt @@ -0,0 +1,6 @@ +2 +2 2 +1 2 +2 1 +3 1 +2 2 diff --git a/codeforces/CowardlyRooks/main_input1.txt b/codeforces/CowardlyRooks/main_input1.txt new file mode 100644 index 0000000..a7b200d --- /dev/null +++ b/codeforces/CowardlyRooks/main_input1.txt @@ -0,0 +1,6 @@ +1 +4 4 +1 4 +2 2 +2 3 +4 1 diff --git a/codeforces/CowardlyRooks/main_output0.txt b/codeforces/CowardlyRooks/main_output0.txt new file mode 100644 index 0000000..b84a237 --- /dev/null +++ b/codeforces/CowardlyRooks/main_output0.txt @@ -0,0 +1,2 @@ +NO +YES diff --git a/codeforces/CowardlyRooks/main_output1.txt b/codeforces/CowardlyRooks/main_output1.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/codeforces/CowardlyRooks/main_output1.txt @@ -0,0 +1 @@ +YES \ No newline at end of file diff --git a/codeforces/Cupboards/main b/codeforces/Cupboards/main new file mode 100755 index 0000000..ca3fa4f Binary files /dev/null and b/codeforces/Cupboards/main differ diff --git a/codeforces/Cupboards/main.cpp b/codeforces/Cupboards/main.cpp new file mode 100644 index 0000000..147e25f --- /dev/null +++ b/codeforces/Cupboards/main.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + int l = 0, r = 0; + for (int i = 0; i < n; ++i) { + int x, y; + cin >> x >> y; + l += x; + r += y; + } + // l = 1 + // r = 3 + // max(n - l, n - r) + int mx = max(n - l, n - r); + if (mx == n - l) { + cout << l + n - r << '\n'; + } else { + cout << r + n - r << '\n'; + } +} diff --git a/codeforces/Cupboards/main_input0.txt b/codeforces/Cupboards/main_input0.txt new file mode 100644 index 0000000..acc2e02 --- /dev/null +++ b/codeforces/Cupboards/main_input0.txt @@ -0,0 +1,6 @@ +5 +0 1 +1 0 +0 1 +1 1 +0 1 diff --git a/codeforces/Cupboards/main_output0.txt b/codeforces/Cupboards/main_output0.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/Cupboards/main_output0.txt @@ -0,0 +1 @@ +3 diff --git a/codeforces/ILove%username/main b/codeforces/ILove%username/main new file mode 100755 index 0000000..e532065 Binary files /dev/null and b/codeforces/ILove%username/main differ diff --git a/codeforces/ILove%username/main.cpp b/codeforces/ILove%username/main.cpp new file mode 100644 index 0000000..3ad1fc9 --- /dev/null +++ b/codeforces/ILove%username/main.cpp @@ -0,0 +1,32 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + vi v(n); + int ans = 0; + for (int i = 0; i < n; i++) { + cin >> v[i]; + } + int mx = v[0], mn = v[0]; + for (int i = 0; i < n; i++) { + if (v[i] > mx || v[i] < mn) { + cerr << v[i] << '\n'; + ans++; + } + mx = max(mx, v[i]); + mn = min(mn, v[i]); + } + cout << ans << '\n'; +} diff --git a/codeforces/ILove%username/main_input0.txt b/codeforces/ILove%username/main_input0.txt new file mode 100644 index 0000000..2a1d81c --- /dev/null +++ b/codeforces/ILove%username/main_input0.txt @@ -0,0 +1,2 @@ +5 +100 50 200 150 200 diff --git a/codeforces/ILove%username/main_input1.txt b/codeforces/ILove%username/main_input1.txt new file mode 100644 index 0000000..e5a37cc --- /dev/null +++ b/codeforces/ILove%username/main_input1.txt @@ -0,0 +1,2 @@ +10 +4664 6496 5814 7010 5762 5736 6944 4850 3698 7242 diff --git a/codeforces/ILove%username/main_output0.txt b/codeforces/ILove%username/main_output0.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/codeforces/ILove%username/main_output0.txt @@ -0,0 +1 @@ +2 diff --git a/codeforces/ILove%username/main_output1.txt b/codeforces/ILove%username/main_output1.txt new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/codeforces/ILove%username/main_output1.txt @@ -0,0 +1 @@ +4 diff --git a/codeforces/Tram/main b/codeforces/Tram/main new file mode 100755 index 0000000..3c01372 Binary files /dev/null and b/codeforces/Tram/main differ diff --git a/codeforces/Tram/main.cpp b/codeforces/Tram/main.cpp new file mode 100644 index 0000000..ff917a6 --- /dev/null +++ b/codeforces/Tram/main.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int mx = 0; + int n; + cin >> n; + vi v(n); + int x, y; + cin >> x >> y; + v[0] = y; + for (int i = 0; i < n - 1; ++i) { + 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/Tram/main_input0.txt b/codeforces/Tram/main_input0.txt new file mode 100644 index 0000000..4a49cc9 --- /dev/null +++ b/codeforces/Tram/main_input0.txt @@ -0,0 +1,5 @@ +4 +0 3 +2 5 +4 2 +4 0 diff --git a/codeforces/Tram/main_output0.txt b/codeforces/Tram/main_output0.txt new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/codeforces/Tram/main_output0.txt @@ -0,0 +1 @@ +6 diff --git a/codeforces/TwoGroups/main b/codeforces/TwoGroups/main new file mode 100755 index 0000000..9c03086 Binary files /dev/null and b/codeforces/TwoGroups/main differ diff --git a/codeforces/TwoGroups/main.cpp b/codeforces/TwoGroups/main.cpp new file mode 100644 index 0000000..0f7a8f9 --- /dev/null +++ b/codeforces/TwoGroups/main.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +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; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + ans += x; + } + cout << abs(ans) << '\n'; + } +} diff --git a/codeforces/TwoGroups/main_input0.txt b/codeforces/TwoGroups/main_input0.txt new file mode 100644 index 0000000..fadd76c --- /dev/null +++ b/codeforces/TwoGroups/main_input0.txt @@ -0,0 +1,9 @@ +4 +2 +10 -10 +4 +-2 -1 11 0 +3 +2 3 2 +5 +-9 2 0 0 -4 diff --git a/codeforces/TwoGroups/main_output0.txt b/codeforces/TwoGroups/main_output0.txt new file mode 100644 index 0000000..5a36ed8 --- /dev/null +++ b/codeforces/TwoGroups/main_output0.txt @@ -0,0 +1,4 @@ +0 +8 +7 +11 diff --git a/contests/Round#828/A/main b/contests/Round#828/A/main new file mode 100755 index 0000000..e25915f Binary files /dev/null and b/contests/Round#828/A/main differ diff --git a/contests/Round#828/A/main.cpp b/contests/Round#828/A/main.cpp new file mode 100644 index 0000000..62a742b --- /dev/null +++ b/contests/Round#828/A/main.cpp @@ -0,0 +1,39 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +string buildString(map &mp, vi &v) { + string s = ""; + for (auto x : v) { + s.push_back(mp[x]); + } + return s; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + int n; + cin >> n; + vi v(n); + for (auto &x : v) cin >> x; + string s; + cin >> s; + map mp; + for (int i = 0; i < n; i++) { + mp[v[i]] = s[i]; + } + // cerr << buildString(mp,v) << '\n'; + cout << (s == buildString(mp, v) ? "YES" : "NO") << '\n'; + } +} diff --git a/contests/Round#828/B/main b/contests/Round#828/B/main new file mode 100755 index 0000000..ff0612d Binary files /dev/null and b/contests/Round#828/B/main differ diff --git a/contests/Round#828/B/main.cpp b/contests/Round#828/B/main.cpp new file mode 100644 index 0000000..e2d3d5d --- /dev/null +++ b/contests/Round#828/B/main.cpp @@ -0,0 +1,48 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + int n, q; + cin >> n >> q; + vector v(n); + int even = 0, odd = 0; + long long ans = 0; + for (int i = 0 ; i < n; i++) { + cin >> v[i]; + odd += (v[i] & 1); + ans += v[i]; + } + even = n - odd; + while (q--) { + int t, x; + cin >> t >> x; + if (t == 0) { + ans += even * x; + if (x & 1) { + odd += even; + even = 0; + } + } else { + ans += odd * x; + if (x & 1) { + even += odd; + odd = 0; + } + } + cout << ans << '\n'; + } + } +} diff --git a/contests/Round#828/B/main_input0.txt b/contests/Round#828/B/main_input0.txt new file mode 100644 index 0000000..2a62cb5 --- /dev/null +++ b/contests/Round#828/B/main_input0.txt @@ -0,0 +1,27 @@ +4 +1 1 +1 +1 1 +3 3 +1 2 4 +0 2 +1 3 +0 5 +6 7 +1 3 2 4 10 48 +1 6 +0 5 +0 4 +0 5 +1 3 +0 12 +0 1 +6 7 +1000000000 1000000000 1000000000 11 15 17 +0 17 +1 10000 +1 51 +0 92 +0 53 +1 16 +0 1 diff --git a/contests/Round#828/B/main_output0.txt b/contests/Round#828/B/main_output0.txt new file mode 100644 index 0000000..6427631 --- /dev/null +++ b/contests/Round#828/B/main_output0.txt @@ -0,0 +1,18 @@ +2 +11 +14 +29 +80 +100 +100 +100 +118 +190 +196 +3000000094 +3000060094 +3000060400 +3000060952 +3000061270 +3000061366 +3000061366 diff --git a/contests/Round#828/C/main b/contests/Round#828/C/main new file mode 100755 index 0000000..6931c26 Binary files /dev/null and b/contests/Round#828/C/main differ diff --git a/contests/Round#828/C/main.cpp b/contests/Round#828/C/main.cpp new file mode 100644 index 0000000..a69f265 --- /dev/null +++ b/contests/Round#828/C/main.cpp @@ -0,0 +1,48 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + int n; + cin >> n; + int m = 0, mx = 0; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + while (x % 2 == 0) { + x /= 2; + m += 1; + } + } + if (m >= n) { + cout << 0 << '\n'; + } else { + int d = n - m, ans = 0; + vector a; + for (int i = n; i >= 1; i--) { + int j = i, cnt = 0; + while (j % 2 == 0) { + cnt += 1; + j /= 2; + } + if (cnt != 0) { + a.push_back(cnt); + } + } + sort(a.rbegin(), a.rend()); + for (int i = 0; i < (int)a.size(); i++) { + ans += 1; + d -= a[i]; + if (d <= 0) { + break; + } + } + cout << (d <= 0 ? ans : -1) << '\n'; + } + } +} diff --git a/contests/Round#828/C/main_input0.txt b/contests/Round#828/C/main_input0.txt new file mode 100644 index 0000000..c507f1f --- /dev/null +++ b/contests/Round#828/C/main_input0.txt @@ -0,0 +1,13 @@ +6 +1 +2 +2 +3 2 +3 +10 6 11 +4 +13 17 1 1 +5 +1 1 12 1 1 +6 +20 7 14 18 3 5 \ No newline at end of file diff --git a/contests/Round#828/C/main_output0.txt b/contests/Round#828/C/main_output0.txt new file mode 100644 index 0000000..994d708 --- /dev/null +++ b/contests/Round#828/C/main_output0.txt @@ -0,0 +1,6 @@ +0 +1 +1 +-1 +2 +1 \ No newline at end of file diff --git a/contests/Round#828/D/main.cpp b/contests/Round#828/D/main.cpp new file mode 100644 index 0000000..8b6b654 --- /dev/null +++ b/contests/Round#828/D/main.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + + } +} diff --git a/contests/Round#828/E/main.cpp b/contests/Round#828/E/main.cpp new file mode 100644 index 0000000..8b6b654 --- /dev/null +++ b/contests/Round#828/E/main.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + + } +} diff --git a/contests/Round#828/F/main.cpp b/contests/Round#828/F/main.cpp new file mode 100644 index 0000000..8b6b654 --- /dev/null +++ b/contests/Round#828/F/main.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + + } +} diff --git a/contests/filtrationContest/C/main b/contests/filtrationContest/C/main index 4fad05f..b207653 100755 Binary files a/contests/filtrationContest/C/main and b/contests/filtrationContest/C/main differ diff --git a/contests/filtrationContest/C/main.cpp b/contests/filtrationContest/C/main.cpp index 0d06899..e3ed80c 100644 --- a/contests/filtrationContest/C/main.cpp +++ b/contests/filtrationContest/C/main.cpp @@ -1,23 +1,19 @@ #include - + using namespace std; - -int64_t fq[22]; - + int main () { - ios_base::sync_with_stdio(false); - cin.tie(NULL); + ios_base::sync_with_stdio(false); + cin.tie(NULL); long long n; cin >> n; - for (int i = 1; i <= n; i++) { - int64_t x; + long long ans = 0; + map fq; + for(int i = 0; i < n; i++) { + long long x; cin >> x; - fq[10 + x]++; + ans += fq[x]; + fq[-x]++; } - int64_t ans = 0; - for (int i = 1;i <= 10; i++) { - ans += fq[10 - i] * fq[10 + i]; - } - ans += fq[10] * (fq[10] - 1) / 2; - cout << ans; + cout << ans << '\n'; } diff --git a/cses/SortingAndSearching/Apartments/main b/cses/SortingAndSearching/Apartments/main new file mode 100755 index 0000000..946f3f6 Binary files /dev/null and b/cses/SortingAndSearching/Apartments/main differ diff --git a/cses/SortingAndSearching/Apartments/main.cpp b/cses/SortingAndSearching/Apartments/main.cpp index ce2b1ae..676f338 100644 --- a/cses/SortingAndSearching/Apartments/main.cpp +++ b/cses/SortingAndSearching/Apartments/main.cpp @@ -3,22 +3,29 @@ using namespace std; +#define all(x) (x).begin(), (x).end() + int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; - vector dsz(n); - for (auto &x : dsz) cin >> x; - vector asz(m); - for (auto &x : asz) cin >> x; set taken; - sort(dsz.begin(), dsz.end()); - sort(asz.begin(), asz.end()); - bool mbigger = m > n; - if (mbigger) { - for (int i = 0; i < m; i++) { + vector v(n); + vector a(m); + for (auto &x : v) cin >> x; + for (auto &x : a) cin >> x; + sort(all(a)); + int ans = 0; + for (int i = 0; i < n; i++) { + auto upper = *upper_bound(all(a), v[i]); + auto lower = *lower_bound(all(a), v[i]); + cerr << upper << " " << lower << "\n"; + if(!taken.count(i) && (upper <= v[i] + k || lower >= v[i] - k)) { + taken.insert(i); + ans++; } } + cout << ans << '\n'; } diff --git a/cses/SortingAndSearching/Apartments/main_input0.txt b/cses/SortingAndSearching/Apartments/main_input0.txt new file mode 100644 index 0000000..c2eddfd --- /dev/null +++ b/cses/SortingAndSearching/Apartments/main_input0.txt @@ -0,0 +1,3 @@ +4 3 5 +60 45 80 60 +30 60 75 diff --git a/cses/SortingAndSearching/Apartments/main_output0.txt b/cses/SortingAndSearching/Apartments/main_output0.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/cses/SortingAndSearching/Apartments/main_output0.txt @@ -0,0 +1 @@ +2 diff --git a/cses/SortingAndSearching/FerrisWheel/main b/cses/SortingAndSearching/FerrisWheel/main new file mode 100755 index 0000000..65b5df9 Binary files /dev/null and b/cses/SortingAndSearching/FerrisWheel/main differ diff --git a/cses/SortingAndSearching/FerrisWheel/main.cpp b/cses/SortingAndSearching/FerrisWheel/main.cpp new file mode 100644 index 0000000..5ad5363 --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +typedef long long ll; +typedef pair ii; +typedef vector vii; +typedef vector vi; + +#define INF 1000000000 + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n, x; + cin >> n >> x; + vi v(n); + for (auto &y : v) cin >> y; + sort(v.begin(), v.end()); + int ans = 0; + int sum = 0; + // 1 2 + // 1 1 1 1 1 1 + // 2 3 7 9 + // 2 5 12 21 + for (int i = 0; i < n; i++) { + sum += v[i]; + if (sum >= x || v[i] > sum) { + sum = 0; + ans++; + } + } + cout << ans << '\n'; +} diff --git a/cses/SortingAndSearching/FerrisWheel/main_input0.txt b/cses/SortingAndSearching/FerrisWheel/main_input0.txt new file mode 100644 index 0000000..8d443f6 --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_input0.txt @@ -0,0 +1,2 @@ +4 10 +7 2 3 9 diff --git a/cses/SortingAndSearching/FerrisWheel/main_input1.txt b/cses/SortingAndSearching/FerrisWheel/main_input1.txt new file mode 100644 index 0000000..78ee919 --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_input1.txt @@ -0,0 +1 @@ +2 3 5 7 9 \ No newline at end of file diff --git a/cses/SortingAndSearching/FerrisWheel/main_input2.txt b/cses/SortingAndSearching/FerrisWheel/main_input2.txt new file mode 100644 index 0000000..93bab7a --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_input2.txt @@ -0,0 +1,2 @@ +4 10 +2 9 11 8 \ No newline at end of file diff --git a/cses/SortingAndSearching/FerrisWheel/main_input3.txt b/cses/SortingAndSearching/FerrisWheel/main_input3.txt new file mode 100644 index 0000000..58a1b3c --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_input3.txt @@ -0,0 +1,2 @@ +6 2 +1 1 1 1 1 1 diff --git a/cses/SortingAndSearching/FerrisWheel/main_output0.txt b/cses/SortingAndSearching/FerrisWheel/main_output0.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_output0.txt @@ -0,0 +1 @@ +3 diff --git a/cses/SortingAndSearching/FerrisWheel/main_output1.txt b/cses/SortingAndSearching/FerrisWheel/main_output1.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_output1.txt @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/cses/SortingAndSearching/FerrisWheel/main_output2.txt b/cses/SortingAndSearching/FerrisWheel/main_output2.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_output2.txt @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/cses/SortingAndSearching/FerrisWheel/main_output3.txt b/cses/SortingAndSearching/FerrisWheel/main_output3.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/cses/SortingAndSearching/FerrisWheel/main_output3.txt @@ -0,0 +1 @@ +3 \ No newline at end of file -- cgit v1.2.3