diff options
67 files changed, 790 insertions, 24 deletions
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<bits/stdc++.h> + +using namespace std; + +typedef long long ll; +typedef pair<int, int> ii; +typedef vector<ii> vii; +typedef vector<int> 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<bits/stdc++.h> + +using namespace std; + +typedef long long ll; +typedef pair<int, int> ii; +typedef vector<ii> vii; +typedef vector<int> 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 Binary files differnew file mode 100755 index 0000000..f8a3206 --- /dev/null +++ b/UVA/PIDigits/main 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<bits/stdc++.h> +#include <iomanip> + +using namespace std; + +typedef long long ll; +typedef pair<int, int> ii; +typedef vector<ii> vii; +typedef vector<int> 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 Binary files differnew file mode 100755 index 0000000..2102f9d --- /dev/null +++ b/codeforces/BanBan/main 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<bits/stdc++.h> + +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<int> 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 Binary files differnew file mode 100755 index 0000000..9768b26 --- /dev/null +++ b/codeforces/CowardlyRooks/main 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<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vvi = vector<vi>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +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<vector<bool>> v(n, vector<bool>(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 Binary files differnew file mode 100755 index 0000000..ca3fa4f --- /dev/null +++ b/codeforces/Cupboards/main 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<bits/stdc++.h> + +using namespace std; + +typedef long long ll; +typedef pair<int, int> ii; +typedef vector<ii> vii; +typedef vector<int> 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 Binary files differnew file mode 100755 index 0000000..e532065 --- /dev/null +++ b/codeforces/ILove%username/main 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<bits/stdc++.h> + +using namespace std; + +typedef long long ll; +typedef pair<int, int> ii; +typedef vector<ii> vii; +typedef vector<int> 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 Binary files differnew file mode 100755 index 0000000..3c01372 --- /dev/null +++ b/codeforces/Tram/main 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<bits/stdc++.h> + +using namespace std; + +typedef long long ll; +typedef pair<int, int> ii; +typedef vector<ii> vii; +typedef vector<int> 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 Binary files differnew file mode 100755 index 0000000..9c03086 --- /dev/null +++ b/codeforces/TwoGroups/main 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<bits/stdc++.h> + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); |
