diff options
76 files changed, 774 insertions, 0 deletions
diff --git a/LinearKeyboard/main b/LinearKeyboard/main Binary files differnew file mode 100755 index 0000000..322a82d --- /dev/null +++ b/LinearKeyboard/main diff --git a/LinearKeyboard/main.cpp b/LinearKeyboard/main.cpp new file mode 100644 index 0000000..96ac0d4 --- /dev/null +++ b/LinearKeyboard/main.cpp @@ -0,0 +1,60 @@ +#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 vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#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}; + +void solve() { + string alphabet, word; + cin >> alphabet; + cin >> word; + map<char, int> mp; + int ans = 0; + for (int i = 0; i < alphabet.size(); i++) { + mp[alphabet[i]] = i + 1; + } + for (auto [key, val] : mp) { + cerr << (char)key << " : " << val << '\n'; + } + for (int i = 1; i < word.size(); i++) { + ans += abs(mp[word[i]] - mp[word[i - 1]]); + } + cout << ans << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + +/* 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/LinearKeyboard/main_input0.txt b/LinearKeyboard/main_input0.txt new file mode 100644 index 0000000..ec6d524 --- /dev/null +++ b/LinearKeyboard/main_input0.txt @@ -0,0 +1,11 @@ +5 +abcdefghijklmnopqrstuvwxyz +hello +abcdefghijklmnopqrstuvwxyz +i +abcdefghijklmnopqrstuvwxyz +codeforces +qwertyuiopasdfghjklzxcvbnm +qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq +qwertyuiopasdfghjklzxcvbnm +abacaba diff --git a/LinearKeyboard/main_output0.txt b/LinearKeyboard/main_output0.txt new file mode 100644 index 0000000..c0a2149 --- /dev/null +++ b/LinearKeyboard/main_output0.txt @@ -0,0 +1,5 @@ +13 +0 +68 +0 +74 diff --git a/TheUltimateSquare/main b/TheUltimateSquare/main Binary files differnew file mode 100755 index 0000000..81afd64 --- /dev/null +++ b/TheUltimateSquare/main diff --git a/TheUltimateSquare/main.cpp b/TheUltimateSquare/main.cpp new file mode 100644 index 0000000..102880d --- /dev/null +++ b/TheUltimateSquare/main.cpp @@ -0,0 +1,53 @@ +#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 vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#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}; + +void solve() { + int n; + cin >> n; + if (n & 1) { + cout << (n / 2) + 1 << '\n'; + } else { + cout << n / 2 << '\n'; + } + +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + +/* 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/TheUltimateSquare/main_input0.txt b/TheUltimateSquare/main_input0.txt new file mode 100644 index 0000000..650d174 --- /dev/null +++ b/TheUltimateSquare/main_input0.txt @@ -0,0 +1,4 @@ +3 +2 +5 +197654321 diff --git a/TheUltimateSquare/main_output0.txt b/TheUltimateSquare/main_output0.txt new file mode 100644 index 0000000..773b55e --- /dev/null +++ b/TheUltimateSquare/main_output0.txt @@ -0,0 +1,3 @@ +1 +3 +98827161 diff --git a/codeforces/AmusingJoke/main b/codeforces/AmusingJoke/main Binary files differnew file mode 100755 index 0000000..df6c17d --- /dev/null +++ b/codeforces/AmusingJoke/main diff --git a/codeforces/AmusingJoke/main.cpp b/codeforces/AmusingJoke/main.cpp new file mode 100644 index 0000000..3dd0fac --- /dev/null +++ b/codeforces/AmusingJoke/main.cpp @@ -0,0 +1,57 @@ +#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 vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#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() { + vi fq1(28), fq2(28); + string s1, s2, s3; + cin >> s1 >> s2 >> s3; + s1 += s2; + for (auto ch : s1) { + fq1[ch - 'A']++; + } + for (auto ch : s3) { + fq2[ch - 'A']++; + } + for (int i = 0; i < 28; i++) { + if (fq1[i] != fq2[i]) { + return "NO"; + } + } + return "YES"; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + 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/AmusingJoke/main_input0.txt b/codeforces/AmusingJoke/main_input0.txt new file mode 100644 index 0000000..40a66fa --- /dev/null +++ b/codeforces/AmusingJoke/main_input0.txt @@ -0,0 +1,3 @@ +SANTACLAUS +DEDMOROZ +SANTAMOROZDEDCLAUS diff --git a/codeforces/AmusingJoke/main_input1.txt b/codeforces/AmusingJoke/main_input1.txt new file mode 100644 index 0000000..72b3b1a --- /dev/null +++ b/codeforces/AmusingJoke/main_input1.txt @@ -0,0 +1,3 @@ +PAPAINOEL +JOULUPUKKI +JOULNAPAOILELUPUKKI diff --git a/codeforces/AmusingJoke/main_input2.txt b/codeforces/AmusingJoke/main_input2.txt new file mode 100644 index 0000000..07f64f4 --- /dev/null +++ b/codeforces/AmusingJoke/main_input2.txt @@ -0,0 +1,3 @@ +BABBONATALE +FATHERCHRISTMAS +BABCHRISTMASBONATALLEFATHER diff --git a/codeforces/AmusingJoke/main_output0.txt b/codeforces/AmusingJoke/main_output0.txt new file mode 100644 index 0000000..f033a50 --- /dev/null +++ b/codeforces/AmusingJoke/main_output0.txt @@ -0,0 +1 @@ +YES diff --git a/codeforces/AmusingJoke/main_output1.txt b/codeforces/AmusingJoke/main_output1.txt new file mode 100644 index 0000000..5e35d1b --- /dev/null +++ b/codeforces/AmusingJoke/main_output1.txt @@ -0,0 +1 @@ +NO diff --git a/codeforces/AmusingJoke/main_output2.txt b/codeforces/AmusingJoke/main_output2.txt new file mode 100644 index 0000000..5e35d1b --- /dev/null +++ b/codeforces/AmusingJoke/main_output2.txt @@ -0,0 +1 @@ +NO diff --git a/codeforces/BanBan/rust-solution/Cargo.lock b/codeforces/BanBan/rust-solution/Cargo.lock new file mode 100644 index 0000000..a85fd87 --- /dev/null +++ b/codeforces/BanBan/rust-solution/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "rust-solution" +version = "0.1.0" diff --git a/codeforces/BanBan/rust-solution/Cargo.toml b/codeforces/BanBan/rust-solution/Cargo.toml new file mode 100644 index 0000000..de6deb6 --- /dev/null +++ b/codeforces/BanBan/rust-solution/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust-solution" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/codeforces/BanBan/rust-solution/src/main.rs b/codeforces/BanBan/rust-solution/src/main.rs new file mode 100644 index 0000000..e1c0c5c --- /dev/null +++ b/codeforces/BanBan/rust-solution/src/main.rs @@ -0,0 +1,31 @@ +fn readi64(input : &mut dyn Iterator<Item = String>) -> i64 { + input.next().unwrap().parse::<i64>().unwrap() +} + + + +fn main() { + let mut lines = std::io::stdin().lines().map(|line| line.unwrap()); + let tt = readi64(&mut lines); + for _ in 0..tt { + let n = readi64(&mut lines); + if n == 1 { + println!("{n}\n1 2\n"); + } else { + println!("{}", n - 1); + let mut v = Vec::with_capacity(n as usize); + let mut cnt = 0; + let mut i = 0; + while cnt != n - 1 && i < n { + if (3 * n - 1 - i) % 3 != 0 { + v[i as usize] = 3 * n - 1 - i; + cnt +=1; + } + i += 1; + } + for x in &v { + println!("{} {}", i * 3 + 1, x); + } + } + } +} diff --git a/codeforces/BanBan/rust-solution/target/.rustc_info.json b/codeforces/BanBan/rust-solution/target/.rustc_info.json new file mode 100644 index 0000000..7b4a303 --- /dev/null +++ b/codeforces/BanBan/rust-solution/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":13623177262638950519,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.64.0 (a55dd71d5 2022-09-19)\nbinary: rustc\ncommit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52\ncommit-date: 2022-09-19\nhost: x86_64-unknown-linux-gnu\nrelease: 1.64.0\nLLVM version: 14.0.6\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/pengu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"15697416045686424142":{"success":false,"status":"exit status: 1","code":1,"stdout":"","stderr":"error: `-Csplit-debuginfo` is unstable on this platform\n\n"}},"successes":{}}
\ No newline at end of file diff --git a/codeforces/BanBan/rust-solution/target/CACHEDIR.TAG b/codeforces/BanBan/rust-solution/target/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/codeforces/BanBan/rust-solution/target/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/codeforces/BanBan/rust-solution/target/debug/.cargo-lock b/codeforces/BanBan/rust-solution/target/debug/.cargo-lock new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codeforces/BanBan/rust-solution/target/debug/.cargo-lock diff --git a/codeforces/BanBan/rust-solution/target/debug/.fingerprint/rust-solution-562fe77d76fddac5/bin-rust-solution b/codeforces/BanBan/rust-solution/target/debug/.fingerprint/rust-solution-562fe77d76fddac5/bin-rust-solution new file mode 100644 index 0000000..0583346 --- /dev/null +++ b/codeforces/BanBan/rust-solution/target/debug/.fingerprint/rust-solution-562fe77d76fddac5/bin-rust-solution @@ -0,0 +1 @@ +fc1ddc6a46b72f83
\ No newline at end of file diff --git a/codeforces/BanBan/rust-solution/target/debug/.fingerprint/rust-solution-562fe77d76fddac5/bin-rust-solution.json b/codeforces/BanBan/rust-solution/target/debug/.fingerprint/rust-solution-562fe77d76fddac5/bin-rust-solution.json new file mode 100644 index 0000000..042bd6c --- /dev/null +++ b/codeforces/BanBan/rust-solution/target/debug/.fingerprint/rust-solution-562fe77d76fddac5/bin-rust-solution.json @@ -0,0 +1 @@ +{"rustc":11934069355019162238,"features":"[]","target":8769653080315079519,"profile":7309141686862299243,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/rust-solution-562fe77d76fddac5/dep-bin-rust-soluti |
