aboutsummaryrefslogtreecommitdiff
path: root/codeforces
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-03-05 20:04:34 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-03-05 20:04:34 +0200
commit90c03b3c6301f5d8908ce3e2dec936a74b035014 (patch)
treee15816a4615f5e03650bf1be41c6867992919987 /codeforces
parentef9dfb5d8bfa705a0c056a2652d298e5ebb763fb (diff)
downloadcompetitive-programming-90c03b3c6301f5d8908ce3e2dec936a74b035014.tar.xz
competitive-programming-90c03b3c6301f5d8908ce3e2dec936a74b035014.zip
Solved a bunch of problems
Diffstat (limited to 'codeforces')
-rwxr-xr-xcodeforces/Asterisk-MinorTemplate/mainbin0 -> 37304 bytes
-rwxr-xr-xcodeforces/Asterisk-MinorTemplate/main.cpp123
-rw-r--r--codeforces/Asterisk-MinorTemplate/main_input0.txt13
-rw-r--r--codeforces/Asterisk-MinorTemplate/main_output0.txt10
-rwxr-xr-xcodeforces/CompleteTheWord/main.cpp92
-rwxr-xr-xcodeforces/CrazyComputer/mainbin0 -> 22480 bytes
-rwxr-xr-xcodeforces/CrazyComputer/main.cpp98
-rw-r--r--codeforces/CrazyComputer/main_input0.txt2
-rw-r--r--codeforces/CrazyComputer/main_input1.txt2
-rw-r--r--codeforces/CrazyComputer/main_output0.txt1
-rw-r--r--codeforces/CrazyComputer/main_output1.txt1
-rwxr-xr-xcodeforces/TypicalInterviewProblem/mainbin0 -> 605664 bytes
-rwxr-xr-xcodeforces/TypicalInterviewProblem/main.cpp102
-rw-r--r--codeforces/TypicalInterviewProblem/main_input0.txt7
-rw-r--r--codeforces/TypicalInterviewProblem/main_output0.txt3
15 files changed, 454 insertions, 0 deletions
diff --git a/codeforces/Asterisk-MinorTemplate/main b/codeforces/Asterisk-MinorTemplate/main
new file mode 100755
index 0000000..837d6d2
--- /dev/null
+++ b/codeforces/Asterisk-MinorTemplate/main
Binary files differ
diff --git a/codeforces/Asterisk-MinorTemplate/main.cpp b/codeforces/Asterisk-MinorTemplate/main.cpp
new file mode 100755
index 0000000..943cc0f
--- /dev/null
+++ b/codeforces/Asterisk-MinorTemplate/main.cpp
@@ -0,0 +1,123 @@
+#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 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};
+
+//pretty printing
+template<typename K, typename V>
+void printm(const map<K, V> &mp) {
+ cerr << "{" << endl;
+ for (auto p : mp) {
+ cerr << " { " << p.first << " : " << p.second << " }\n";
+ }
+ cerr << "}" << endl;
+}
+template<typename T>
+void printv(const vector<T> &v) {
+ cerr << "[";
+ for (int i = 0; i < v.size(); i++) {
+ if (i == v.size() - 1) {
+ cerr << v[i];
+ } else {
+ cerr << v[i] << ", ";
+ }
+ }
+ cerr << "]\n";
+}
+
+template<typename T>
+void printvv(const vector<vector<T>> &v) {
+ cerr << "[\n";
+ for (auto &vec : v) {
+ cout << " ";
+ printv(vec);
+ }
+ cerr << "]\n";
+}
+void print() {
+ cerr << "\n";
+}
+
+template<typename T, typename... TS>
+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() {
+ string s1, s2;
+ cin >> s1;
+ cin >> s2;
+ if (s1[0] == s2[0]) {
+ cout << "YES\n";
+ cout << s1[0];
+ cout << "*\n";
+ } else if(s1[s1.length() - 1] == s2[s2.length() - 1]) {
+ cout << "YES\n";
+ cout << "*";
+ cout << s1[s1.length() - 1] << '\n';
+ } else {
+ int n = s1.length();
+ int m = s2.length();
+ vector<string> substrs1;
+ vector<string> substrs2;
+ for (int i = 0; i < s1.length(); i++) {
+ substrs1.pb(s1.substr(i, 2));
+ }
+ for (int i = 0; i < s2.length(); i++) {
+ substrs2.pb(s2.substr(i, 2));
+ }
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j < m; j++) {
+ if (substrs1[i] == substrs2[j]) {
+ string ans = "YES\n*" + substrs1[i] + "*\n";
+ cout << ans;
+ return;
+ }
+ }
+ }
+ 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/Asterisk-MinorTemplate/main_input0.txt b/codeforces/Asterisk-MinorTemplate/main_input0.txt
new file mode 100644
index 0000000..95f28a8
--- /dev/null
+++ b/codeforces/Asterisk-MinorTemplate/main_input0.txt
@@ -0,0 +1,13 @@
+6
+aaab
+zzzb
+codeforces
+atcoder
+codeforces
+tokitlx
+aaaa
+aaaaaa
+abcd
+abcd
+c
+f
diff --git a/codeforces/Asterisk-MinorTemplate/main_output0.txt b/codeforces/Asterisk-MinorTemplate/main_output0.txt
new file mode 100644
index 0000000..b594c1e
--- /dev/null
+++ b/codeforces/Asterisk-MinorTemplate/main_output0.txt
@@ -0,0 +1,10 @@
+YES
+*b
+YES
+*co*
+NO
+YES
+a*a*a*a
+YES
+abcd
+NO
diff --git a/codeforces/CompleteTheWord/main.cpp b/codeforces/CompleteTheWord/main.cpp
new file mode 100755
index 0000000..6e8522f
--- /dev/null
+++ b/codeforces/CompleteTheWord/main.cpp
@@ -0,0 +1,92 @@
+#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 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};
+
+//pretty printing
+template<typename K, typename V>
+void printm(const map<K, V> &mp) {
+ cerr << "{" << endl;
+ for (auto p : mp) {
+ cerr << " { " << p.first << " : " << p.second << " }\n";
+ }
+ cerr << "}" << endl;
+}
+template<typename T>
+void printv(const vector<T> &v) {
+ cerr << "[";
+ for (int i = 0; i < v.size(); i++) {
+ if (i == v.size() - 1) {
+ cerr << v[i];
+ } else {
+ cerr << v[i] << ", ";
+ }
+ }
+ cerr << "]\n";
+}
+
+template<typename T>
+void printvv(const vector<vector<T>> &v) {
+ cerr << "[\n";
+ for (auto &vec : v) {
+ cout << " ";
+ printv(vec);
+ }
+ cerr << "]\n";
+}
+void print() {
+ cerr << "\n";
+}
+
+template<typename T, typename... TS>
+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() {
+ string s;
+ cin >> s;
+
+
+}
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--) {
+ solve();
+ }
+}
+
+
diff --git a/codeforces/CrazyComputer/main b/codeforces/CrazyComputer/main
new file mode 100755
index 0000000..1b83fe9
--- /dev/null
+++ b/codeforces/CrazyComputer/main
Binary files differ
diff --git a/codeforces/CrazyComputer/main.cpp b/codeforces/CrazyComputer/main.cpp
new file mode 100755
index 0000000..f1e73a5
--- /dev/null
+++ b/codeforces/CrazyComputer/main.cpp
@@ -0,0 +1,98 @@
+#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 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};
+
+//pretty printing
+template<typename K, typename V>
+void printm(const map<K, V> &mp) {
+ cerr << "{" << endl;
+ for (auto p : mp) {
+ cerr << " { " << p.first << " : " << p.second << " }\n";
+ }
+ cerr << "}" << endl;
+}
+template<typename T>
+void printv(const vector<T> &v) {
+ cerr << "[";
+ for (int i = 0; i < v.size(); i++) {
+ if (i == v.size() - 1) {
+ cerr << v[i];
+ } else {
+ cerr << v[i] << ", ";
+ }
+ }
+ cerr << "]\n";
+}
+
+template<typename T>
+void printvv(const vector<vector<T>> &v) {
+ cerr << "[\n";
+ for (auto &vec : v) {
+ cout << " ";
+ printv(vec);
+ }
+ cerr << "]\n";
+}
+void print() {
+ cerr << "\n";
+}
+
+template<typename T, typename... TS>
+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, c;
+ cin >> n >> c;
+ vi v(n);
+ for (auto &x : v) cin >> x;
+ int ans = 1;
+ for (int i = 1; i < n; i++) {
+ if (v[i] - v[i - 1] > c) {
+ ans = 1;
+ } else {
+ ans++;
+ }
+ }
+ cout << ans << '\n';
+
+}
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ solve();
+}
+
+
diff --git a/codeforces/CrazyComputer/main_input0.txt b/codeforces/CrazyComputer/main_input0.txt
new file mode 100644
index 0000000..702cd09
--- /dev/null
+++ b/codeforces/CrazyComputer/main_input0.txt
@@ -0,0 +1,2 @@
+6 5
+1 3 8 14 19 20
diff --git a/codeforces/CrazyComputer/main_input1.txt b/codeforces/CrazyComputer/main_input1.txt
new file mode 100644
index 0000000..dbcc569
--- /dev/null
+++ b/codeforces/CrazyComputer/main_input1.txt
@@ -0,0 +1,2 @@
+6 1
+1 3 5 7 9 10
diff --git a/codeforces/CrazyComputer/main_output0.txt b/codeforces/CrazyComputer/main_output0.txt
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/codeforces/CrazyComputer/main_output0.txt
@@ -0,0 +1 @@
+3
diff --git a/codeforces/CrazyComputer/main_output1.txt b/codeforces/CrazyComputer/main_output1.txt
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/codeforces/CrazyComputer/main_output1.txt
@@ -0,0 +1 @@
+2
diff --git a/codeforces/TypicalInterviewProblem/main b/codeforces/TypicalInterviewProblem/main
new file mode 100755
index 0000000..c00327c
--- /dev/null
+++ b/codeforces/TypicalInterviewProblem/main
Binary files differ
diff --git a/codeforces/TypicalInterviewProblem/main.cpp b/codeforces/TypicalInterviewProblem/main.cpp
new file mode 100755
index 0000000..51f37c3
--- /dev/null
+++ b/codeforces/TypicalInterviewProblem/main.cpp
@@ -0,0 +1,102 @@
+#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 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};
+
+//pretty printing
+template<typename K, typename V>
+void printm(const map<K, V> &mp) {
+ cerr << "{" << endl;
+ for (auto p : mp) {
+ cerr << " { " << p.first << " : " << p.second << " }\n";
+ }
+ cerr << "}" << endl;
+}
+template<typename T>
+void printv(const vector<T> &v) {
+ cerr << "[";
+ for (int i = 0; i < v.size(); i++) {
+ if (i == v.size() - 1) {
+ cerr << v[i];
+ } else {
+ cerr << v[i] << ", ";
+ }
+ }
+ cerr << "]\n";
+}
+
+template<typename T>
+void printvv(const vector<vector<T>> &v) {
+ cerr << "[\n";
+ for (auto &vec : v) {
+ cout << " ";
+ printv(vec);
+ }
+ cerr << "]\n";
+}
+void print() {
+ cerr << "\n";
+}
+
+template<typename T, typename... TS>
+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
+ */
+// 3 5 6 9 10 12 15 18 20 21 24 25 27 30
+// F B F F B F FB F B F F B F FB
+// FBFFBFFB FBFFBFFB
+
+void solve() {
+ int n;
+ string s;
+ cin >> n;
+ cin >> s;
+ string fb = "FBFFBFFBFBFFBFFBFBFFBFFBFBFFBFFB";
+ if (regex_match(fb, regex(".*" + s + ".*"))) {
+ 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/TypicalInterviewProblem/main_input0.txt b/codeforces/TypicalInterviewProblem/main_input0.txt
new file mode 100644
index 0000000..2abcb4f
--- /dev/null
+++ b/codeforces/TypicalInterviewProblem/main_input0.txt
@@ -0,0 +1,7 @@
+3
+3
+FFB
+8
+BFFBFFBF
+3
+BBB
diff --git a/codeforces/TypicalInterviewProblem/main_output0.txt b/codeforces/TypicalInterviewProblem/main_output0.txt
new file mode 100644
index 0000000..5ae1e3d
--- /dev/null
+++ b/codeforces/TypicalInterviewProblem/main_output0.txt
@@ -0,0 +1,3 @@
+YES
+YES
+NO