From 3a89fc707253f75f46fd5a4822817f1fd5156c40 Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Mon, 30 May 2022 00:18:17 +0200 Subject: Made that every problem is its own folder to make building the code a smooth operation with a shortcut --- contests/05-05-2022(Div.3)/A/A | Bin 17848 -> 679 bytes contests/05-05-2022(Div.3)/A/A.cpp | 42 ----------------- contests/05-05-2022(Div.3)/B/B | Bin 33024 -> 808 bytes contests/05-05-2022(Div.3)/B/B.cpp | 48 ------------------- contests/05-05-2022(Div.3)/C/C.cpp | 1 - contests/05-05-2022(Div.3)/C/C/C.cpp | 1 + contests/05-05-2022(Div.3)/D/D.cpp | 0 contests/05-05-2022(Div.3)/D/D/D.cpp | 0 contests/05-05-2022(Div.3)/E/E.cpp | 0 contests/05-05-2022(Div.3)/E/E/E.cpp | 0 contests/05-05-2022(Div.3)/F/F.cpp | 0 contests/05-05-2022(Div.3)/F/F/F.cpp | 0 contests/08-03-2022(Div.3)/A | Bin 18880 -> 451 bytes contests/08-03-2022(Div.3)/A.cpp | 25 ---------- .../A_Deletions_of_Two_Adjacent_Letters | Bin 18664 -> 722 bytes .../A_Deletions_of_Two_Adjacent_Letters.cpp | 37 --------------- contests/08-03-2022(Div.3)/B | Bin 17688 -> 410 bytes contests/08-03-2022(Div.3)/B.cpp | 23 ---------- contests/08-03-2022(Div.3)/B_DIV_MOD.cpp | 23 ---------- contests/08-03-2022(Div.3)/B_DIV_MOD/B_DIV_MOD.cpp | 23 ++++++++++ contests/08-03-2022(Div.3)/C.cpp | 22 --------- contests/08-03-2022(Div.3)/C/C.cpp | 22 +++++++++ contests/08-03-2022(Div.3)/D.cpp | 20 -------- contests/08-03-2022(Div.3)/D/D.cpp | 20 ++++++++ contests/08-03-2022(Div.3)/E.cpp | 9 ---- contests/08-03-2022(Div.3)/E/E.cpp | 9 ++++ contests/21-04-2022(Div.4)/A | Bin 17792 -> 391 bytes contests/21-04-2022(Div.4)/A.cpp | 23 ---------- contests/21-04-2022(Div.4)/B | Bin 47400 -> 454 bytes contests/21-04-2022(Div.4)/B.cpp | 30 ------------ contests/21-04-2022(Div.4)/E | Bin 24728 -> 448 bytes contests/21-04-2022(Div.4)/E.cpp | 25 ---------- contests/21-04-2022(Div.4)/F | Bin 22712 -> 62 bytes contests/21-04-2022(Div.4)/F.cpp | 7 --- contests/Round#788/A(2_pointers).cpp | 29 ------------ contests/Round#788/A(2_pointers)/A(2_pointers).cpp | 29 ++++++++++++ contests/Round#788/A.cpp | 50 -------------------- contests/Round#788/A/A.cpp | 50 ++++++++++++++++++++ contests/Round#788/B.cpp | 7 --- contests/Round#788/B/B.cpp | 7 +++ contests/Round#788/C.cpp | 7 --- contests/Round#788/C/C.cpp | 7 +++ contests/Round#788/D.cpp | 7 --- contests/Round#788/D/D.cpp | 7 +++ contests/Round#788/E.cpp | 7 --- contests/Round#788/E/E.cpp | 7 +++ contests/Round#788/F.cpp | 7 --- contests/Round#788/F/F.cpp | 7 +++ contests/Round#790/10-10-2022(Div4)/B.cpp | 25 ---------- contests/Round#790/10-10-2022(Div4)/B/B.cpp | 25 ++++++++++ contests/Round#790/10-10-2022(Div4)/C.cpp | 28 ----------- contests/Round#790/10-10-2022(Div4)/C/C.cpp | 28 +++++++++++ contests/Round#790/10-10-2022(Div4)/D.cpp | 51 --------------------- contests/Round#790/10-10-2022(Div4)/D/D.cpp | 51 +++++++++++++++++++++ 54 files changed, 293 insertions(+), 553 deletions(-) mode change 100755 => 100644 contests/05-05-2022(Div.3)/A/A delete mode 100644 contests/05-05-2022(Div.3)/A/A.cpp mode change 100755 => 100644 contests/05-05-2022(Div.3)/B/B delete mode 100644 contests/05-05-2022(Div.3)/B/B.cpp delete mode 100644 contests/05-05-2022(Div.3)/C/C.cpp create mode 100644 contests/05-05-2022(Div.3)/C/C/C.cpp delete mode 100644 contests/05-05-2022(Div.3)/D/D.cpp create mode 100644 contests/05-05-2022(Div.3)/D/D/D.cpp delete mode 100644 contests/05-05-2022(Div.3)/E/E.cpp create mode 100644 contests/05-05-2022(Div.3)/E/E/E.cpp delete mode 100644 contests/05-05-2022(Div.3)/F/F.cpp create mode 100644 contests/05-05-2022(Div.3)/F/F/F.cpp mode change 100755 => 100644 contests/08-03-2022(Div.3)/A delete mode 100644 contests/08-03-2022(Div.3)/A.cpp mode change 100755 => 100644 contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters delete mode 100644 contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters.cpp mode change 100755 => 100644 contests/08-03-2022(Div.3)/B delete mode 100644 contests/08-03-2022(Div.3)/B.cpp delete mode 100644 contests/08-03-2022(Div.3)/B_DIV_MOD.cpp create mode 100644 contests/08-03-2022(Div.3)/B_DIV_MOD/B_DIV_MOD.cpp delete mode 100644 contests/08-03-2022(Div.3)/C.cpp create mode 100644 contests/08-03-2022(Div.3)/C/C.cpp delete mode 100644 contests/08-03-2022(Div.3)/D.cpp create mode 100644 contests/08-03-2022(Div.3)/D/D.cpp delete mode 100644 contests/08-03-2022(Div.3)/E.cpp create mode 100644 contests/08-03-2022(Div.3)/E/E.cpp mode change 100755 => 100644 contests/21-04-2022(Div.4)/A delete mode 100644 contests/21-04-2022(Div.4)/A.cpp mode change 100755 => 100644 contests/21-04-2022(Div.4)/B delete mode 100644 contests/21-04-2022(Div.4)/B.cpp mode change 100755 => 100644 contests/21-04-2022(Div.4)/E delete mode 100644 contests/21-04-2022(Div.4)/E.cpp mode change 100755 => 100644 contests/21-04-2022(Div.4)/F delete mode 100644 contests/21-04-2022(Div.4)/F.cpp delete mode 100644 contests/Round#788/A(2_pointers).cpp create mode 100644 contests/Round#788/A(2_pointers)/A(2_pointers).cpp delete mode 100644 contests/Round#788/A.cpp create mode 100644 contests/Round#788/A/A.cpp delete mode 100644 contests/Round#788/B.cpp create mode 100644 contests/Round#788/B/B.cpp delete mode 100644 contests/Round#788/C.cpp create mode 100644 contests/Round#788/C/C.cpp delete mode 100644 contests/Round#788/D.cpp create mode 100644 contests/Round#788/D/D.cpp delete mode 100644 contests/Round#788/E.cpp create mode 100644 contests/Round#788/E/E.cpp delete mode 100644 contests/Round#788/F.cpp create mode 100644 contests/Round#788/F/F.cpp delete mode 100644 contests/Round#790/10-10-2022(Div4)/B.cpp create mode 100644 contests/Round#790/10-10-2022(Div4)/B/B.cpp delete mode 100644 contests/Round#790/10-10-2022(Div4)/C.cpp create mode 100644 contests/Round#790/10-10-2022(Div4)/C/C.cpp delete mode 100644 contests/Round#790/10-10-2022(Div4)/D.cpp create mode 100644 contests/Round#790/10-10-2022(Div4)/D/D.cpp (limited to 'contests') diff --git a/contests/05-05-2022(Div.3)/A/A b/contests/05-05-2022(Div.3)/A/A old mode 100755 new mode 100644 index 7c1c04e..2f5fb6b Binary files a/contests/05-05-2022(Div.3)/A/A and b/contests/05-05-2022(Div.3)/A/A differ diff --git a/contests/05-05-2022(Div.3)/A/A.cpp b/contests/05-05-2022(Div.3)/A/A.cpp deleted file mode 100644 index 2f5fb6b..0000000 --- a/contests/05-05-2022(Div.3)/A/A.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include - -using namespace std; - -int main() { - int tt,a,b,c,x,y,remX,remY; - cin >> tt; - while (tt--) { - cin >> a >> b >> c >> x >> y; - if(a > x && b < y) { - remX = 0; - remY = y - b; - } - else if (a < x && b > y) { - remX = x - a; - remY = 0; - } - else if (a > x && b > y) { - remX =0; - remY =0; - } - else { - remX = x - a; - remY = y - b; - } - if(c == 0) { - if(a >= x && b >= y) { - cout << "YES" << endl; - } - else { - cout << "NO" << endl; - } - } - else if(c >= remX + remY) { - cout << "YES" << endl; - } - else { - cout << "NO" << endl; - } - - } -} diff --git a/contests/05-05-2022(Div.3)/B/B b/contests/05-05-2022(Div.3)/B/B old mode 100755 new mode 100644 index af9715e..27c4853 Binary files a/contests/05-05-2022(Div.3)/B/B and b/contests/05-05-2022(Div.3)/B/B differ diff --git a/contests/05-05-2022(Div.3)/B/B.cpp b/contests/05-05-2022(Div.3)/B/B.cpp deleted file mode 100644 index 27c4853..0000000 --- a/contests/05-05-2022(Div.3)/B/B.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -using namespace std; - -bool isIncreasing(vector v){ - for(int i = 0; i < v.size() - 1; i++) { - if(v[i] >= v[i+1]) { - return false; - } - } - return true; -} -int getIndex(vector v){ - int index; - for(int i = 0; i < v.size(); i++) { - vector v2(i+1); - for(int j = 0; j <= i;j++){ - index = j; - v2[j] = v[j]; - } - if(!isIncreasing(v2)) { - return index; - } - } - return -1; -} - -int main () { - int tt, n; - cin >> tt; - while(tt--) { - cin >> n; - vector v(n); - for(auto &x : v) { - cin >> x; - } - int idx = getIndex(v); - vector rem(v.size() - idx); - if(idx == -1) { - cout << "0" << endl; - } else { - for(int i = 0;i < v.size() - idx; i++) { - rem[i] = v[idx + i]; - } - } - } - -} diff --git a/contests/05-05-2022(Div.3)/C/C.cpp b/contests/05-05-2022(Div.3)/C/C.cpp deleted file mode 100644 index 8b13789..0000000 --- a/contests/05-05-2022(Div.3)/C/C.cpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/contests/05-05-2022(Div.3)/C/C/C.cpp b/contests/05-05-2022(Div.3)/C/C/C.cpp new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/contests/05-05-2022(Div.3)/C/C/C.cpp @@ -0,0 +1 @@ + diff --git a/contests/05-05-2022(Div.3)/D/D.cpp b/contests/05-05-2022(Div.3)/D/D.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/contests/05-05-2022(Div.3)/D/D/D.cpp b/contests/05-05-2022(Div.3)/D/D/D.cpp new file mode 100644 index 0000000..e69de29 diff --git a/contests/05-05-2022(Div.3)/E/E.cpp b/contests/05-05-2022(Div.3)/E/E.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/contests/05-05-2022(Div.3)/E/E/E.cpp b/contests/05-05-2022(Div.3)/E/E/E.cpp new file mode 100644 index 0000000..e69de29 diff --git a/contests/05-05-2022(Div.3)/F/F.cpp b/contests/05-05-2022(Div.3)/F/F.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/contests/05-05-2022(Div.3)/F/F/F.cpp b/contests/05-05-2022(Div.3)/F/F/F.cpp new file mode 100644 index 0000000..e69de29 diff --git a/contests/08-03-2022(Div.3)/A b/contests/08-03-2022(Div.3)/A old mode 100755 new mode 100644 index a2ce84f..741b57a Binary files a/contests/08-03-2022(Div.3)/A and b/contests/08-03-2022(Div.3)/A differ diff --git a/contests/08-03-2022(Div.3)/A.cpp b/contests/08-03-2022(Div.3)/A.cpp deleted file mode 100644 index 741b57a..0000000 --- a/contests/08-03-2022(Div.3)/A.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -using namespace std; - -int main(){ - int tt; - cin >> tt; - while(tt--){ - string word; - char ch; - cin >> word; - cin >> ch; - int len = word.length(); - if(word[len/2 + 1] == ch){ - cout << word[len/2 + 1] << endl; - cout << ch << endl; - cout << "YES" << "\n"; - } - else{ - cout << "NO" << "\n"; - } - } - - return 0; -} \ No newline at end of file diff --git a/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters b/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters old mode 100755 new mode 100644 index c79eb1d..3f7daa2 Binary files a/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters and b/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters differ diff --git a/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters.cpp b/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters.cpp deleted file mode 100644 index 3f7daa2..0000000 --- a/contests/08-03-2022(Div.3)/A_Deletions_of_Two_Adjacent_Letters.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include - -using namespace std; - -void findMultOcc(vector &indices, string str, char ch){ - for(int i = 0; i < str.length();i++){ - if(str[i] == ch){ - indices.push_back(i); - } - } -} - -string solve(vector indices){ - for(int i = 0; i < indices.size(); i++) - { - if(indices[i] >= 0 && indices[i] % 2 == 0){ - return "YES"; - } - } - return "NO"; -} - -int main(){ - int tt; - cin >> tt; - while(tt--){ - vector indices; - string word; - char ch; - cin >> word; - cin >> ch; - findMultOcc(indices, word, ch); - cout << solve(indices) << '\n'; - } - - return 0; -} diff --git a/contests/08-03-2022(Div.3)/B b/contests/08-03-2022(Div.3)/B old mode 100755 new mode 100644 index b11c838..dd8bb54 Binary files a/contests/08-03-2022(Div.3)/B and b/contests/08-03-2022(Div.3)/B differ diff --git a/contests/08-03-2022(Div.3)/B.cpp b/contests/08-03-2022(Div.3)/B.cpp deleted file mode 100644 index dd8bb54..0000000 --- a/contests/08-03-2022(Div.3)/B.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -using namespace std; - -int modDiv(int r, int a){ - // law r % a == 0, return r-1 % a + r-1 /a, else return r % a + r /a; - if(r % a == 0){ - return (r-1) % a + (r-1)/a; - } - return r % a + r / a; -} - -int main(){ - int tt; - while(tt--){ - cout << "tt: " << tt; - int l, r, a; - cin >> l >> r >> a; - cout << modDiv(r, a); - } - - return 0; -} \ No newline at end of file diff --git a/contests/08-03-2022(Div.3)/B_DIV_MOD.cpp b/contests/08-03-2022(Div.3)/B_DIV_MOD.cpp deleted file mode 100644 index f861b3b..0000000 --- a/contests/08-03-2022(Div.3)/B_DIV_MOD.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -using namespace std; - -int modDiv(int r, int a){ - // law r % a == 0, return r-1 % a + r-1 /a, else return r % a + r /a; - if(r % a == 0){ - return (r-1) % a + (r-1)/a; - } - return r % a + r / a; -} - -int main(){ - int tt; - cin >> tt; - while(tt--){ - int l, r, a; - cin >> l >> r >> a; - cout << modDiv(r, a) << endl; - } - - return 0; -} diff --git a/contests/08-03-2022(Div.3)/B_DIV_MOD/B_DIV_MOD.cpp b/contests/08-03-2022(Div.3)/B_DIV_MOD/B_DIV_MOD.cpp new file mode 100644 index 0000000..f861b3b --- /dev/null +++ b/contests/08-03-2022(Div.3)/B_DIV_MOD/B_DIV_MOD.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int modDiv(int r, int a){ + // law r % a == 0, return r-1 % a + r-1 /a, else return r % a + r /a; + if(r % a == 0){ + return (r-1) % a + (r-1)/a; + } + return r % a + r / a; +} + +int main(){ + int tt; + cin >> tt; + while(tt--){ + int l, r, a; + cin >> l >> r >> a; + cout << modDiv(r, a) << endl; + } + + return 0; +} diff --git a/contests/08-03-2022(Div.3)/C.cpp b/contests/08-03-2022(Div.3)/C.cpp deleted file mode 100644 index f63ebcd..0000000 --- a/contests/08-03-2022(Div.3)/C.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include - -using namespace std; - -int main(){ - int tt; - cin >> tt; - while(tt--){ - list ls; - int len; - int x; - cin >> len; - for(int i = 0; i < len; i++){ - cin >> x; - ls.push_back(x); - } - - - } - - return 0; -} \ No newline at end of file diff --git a/contests/08-03-2022(Div.3)/C/C.cpp b/contests/08-03-2022(Div.3)/C/C.cpp new file mode 100644 index 0000000..f63ebcd --- /dev/null +++ b/contests/08-03-2022(Div.3)/C/C.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main(){ + int tt; + cin >> tt; + while(tt--){ + list ls; + int len; + int x; + cin >> len; + for(int i = 0; i < len; i++){ + cin >> x; + ls.push_back(x); + } + + + } + + return 0; +} \ No newline at end of file diff --git a/contests/08-03-2022(Div.3)/D.cpp b/contests/08-03-2022(Div.3)/D.cpp deleted file mode 100644 index 0572f03..0000000 --- a/contests/08-03-2022(Div.3)/D.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include - -using namespace std; - -int solve() -{ - -} - -int main(){ - int tt; - cin >> tt; - while(tt--){ - - - } - - - return 0; -} diff --git a/contests/08-03-2022(Div.3)/D/D.cpp b/contests/08-03-2022(Div.3)/D/D.cpp new file mode 100644 index 0000000..0572f03 --- /dev/null +++ b/contests/08-03-2022(Div.3)/D/D.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int solve() +{ + +} + +int main(){ + int tt; + cin >> tt; + while(tt--){ + + + } + + + return 0; +} diff --git a/contests/08-03-2022(Div.3)/E.cpp b/contests/08-03-2022(Div.3)/E.cpp deleted file mode 100644 index 2601cd5..0000000 --- a/contests/08-03-2022(Div.3)/E.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -using namespace std; - -int main(){ - int tt; - - return 0; -} \ No newline at end of file diff --git a/contests/08-03-2022(Div.3)/E/E.cpp b/contests/08-03-2022(Div.3)/E/E.cpp new file mode 100644 index 0000000..2601cd5 --- /dev/null +++ b/contests/08-03-2022(Div.3)/E/E.cpp @@ -0,0 +1,9 @@ +#include + +using namespace std; + +int main(){ + int tt; + + return 0; +} \ No newline at end of file diff --git a/contests/21-04-2022(Div.4)/A b/contests/21-04-2022(Div.4)/A old mode 100755 new mode 100644 index 58be759..35c326e Binary files a/contests/21-04-2022(Div.4)/A and b/contests/21-04-2022(Div.4)/A differ diff --git a/contests/21-04-2022(Div.4)/A.cpp b/contests/21-04-2022(Div.4)/A.cpp deleted file mode 100644 index 35c326e..0000000 --- a/contests/21-04-2022(Div.4)/A.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -using namespace std; - -int main(){ - int tt, x; - cin >> tt; - while(tt--){ - cin >> x; - if(x >= 1900){ - cout << "Division 1" << '\n'; - } - else if(x >= 1600 && x <= 1899){ - cout << "Division 2" << '\n'; - } - else if(x >= 1400 && x <= 1599){ - cout << "Division 3" << '\n'; - } - else{ - cout << "Division 4" << '\n'; - } - } -} diff --git a/contests/21-04-2022(Div.4)/B b/contests/21-04-2022(Div.4)/B old mode 100755 new mode 100644 index 6a9b6ab..d1b3e98 Binary files a/contests/21-04-2022(Div.4)/B and b/contests/21-04-2022(Div.4)/B differ diff --git a/contests/21-04-2022(Div.4)/B.cpp b/contests/21-04-2022(Div.4)/B.cpp deleted file mode 100644 index d1b3e98..0000000 --- a/contests/21-04-2022(Div.4)/B.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -using namespace std; - -auto solve(map m){ - for(auto x : m){ - if(x.second >= 3){ - return x.first; - } - } - return -1; -} - -int main(){ - int tt, x, n; - cin >> tt; - while(tt--){ - map frq; - vector v; - cin >> n; - for(int i = 0; i < n; i++){ - cin >> x; - frq[x]++; - } - // for(auto &x : frq){ - // v.push_back(x.second); - // } - cout << solve(frq) << endl; - } -} diff --git a/contests/21-04-2022(Div.4)/E b/contests/21-04-2022(Div.4)/E old mode 100755 new mode 100644 index 0e57ed4..7fac1a5 Binary files a/contests/21-04-2022(Div.4)/E and b/contests/21-04-2022(Div.4)/E differ diff --git a/contests/21-04-2022(Div.4)/E.cpp b/contests/21-04-2022(Div.4)/E.cpp deleted file mode 100644 index 7fac1a5..0000000 --- a/contests/21-04-2022(Div.4)/E.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -using namespace std; - -int main(){ - int tt, n, count; - cin >> tt; - while(tt--){ - string str; - cin >> n; - count = 0; - vector v(n); - for(int i = 0; i < n; i++){ - cin >> v[i]; - } - for(int i = 0; i < v.size(); i++){ - for(int j = i+1; j < v.size()-1; j++){ - if(v[i][0] != v[j][0] || v[i][1] != v[j][1]){ - count++; - } - } - } - cout << count << endl; - } -} diff --git a/contests/21-04-2022(Div.4)/F b/contests/21-04-2022(Div.4)/F old mode 100755 new mode 100644 index b87fe94..4ab1a8c Binary files a/contests/21-04-2022(Div.4)/F and b/contests/21-04-2022(Div.4)/F differ diff --git a/contests/21-04-2022(Div.4)/F.cpp b/contests/21-04-2022(Div.4)/F.cpp deleted file mode 100644 index 4ab1a8c..0000000 --- a/contests/21-04-2022(Div.4)/F.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std; - -int main(){ - -} diff --git a/contests/Round#788/A(2_pointers).cpp b/contests/Round#788/A(2_pointers).cpp deleted file mode 100644 index 5d56719..0000000 --- a/contests/Round#788/A(2_pointers).cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -using namespace std; -int main () { - int tt; - cin >> tt; - while (tt--) { - int n; - cin >> n; - vector v(n); - for(auto &x : v) { - cin >> x; - } - int l = 0, r = v.size() - 1; - while(r > l) { - while(v[l] < 0) { - l++; - } - while(v[r] > 0) { - r--; - } - if(l > r) break; - v[l] = -v[l]; - v[r] = -v[r]; - } - cout << (is_sorted(v.begin(), v.end()) ? "YES" : "NO"); - } -} - - diff --git a/contests/Round#788/A(2_pointers)/A(2_pointers).cpp b/contests/Round#788/A(2_pointers)/A(2_pointers).cpp new file mode 100644 index 0000000..5d56719 --- /dev/null +++ b/contests/Round#788/A(2_pointers)/A(2_pointers).cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +int main () { + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + vector v(n); + for(auto &x : v) { + cin >> x; + } + int l = 0, r = v.size() - 1; + while(r > l) { + while(v[l] < 0) { + l++; + } + while(v[r] > 0) { + r--; + } + if(l > r) break; + v[l] = -v[l]; + v[r] = -v[r]; + } + cout << (is_sorted(v.begin(), v.end()) ? "YES" : "NO"); + } +} + + diff --git a/contests/Round#788/A.cpp b/contests/Round#788/A.cpp deleted file mode 100644 index ada8036..0000000 --- a/contests/Round#788/A.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include - -using namespace std; - -string solve(vector v) { - int p = 0; - int n = 0; - for(int i = 0; i < v.size(); i++) { - if(v[i] > 0) { - p++; - } - else{ - n++; - } - } - int loop = min(p, n); - int loop1 = loop; - for(int i = 0; i < v.size(); i++) { - if(v[i] > 0 && loop != 0) { - v[i] = -v[i]; - loop--; - } - } - loop = min(p, n); - for(int i = v.size() - 1; i > 0; i--) { - if(v[i] < 0 && loop1 != 0) { - v[i] = -v[i]; - loop1--; - } - } - if(is_sorted(v.begin(), v.end())) { - return "YES"; - } - return "NO"; -} - - -int main () { - int tt; - cin >> tt; - while (tt--) { - int n; - cin >> n; - vector v(n); - for(auto &x : v) { - cin >> x; - } - cout << solve(v) << endl; - } -} diff --git a/contests/Round#788/A/A.cpp b/contests/Round#788/A/A.cpp new file mode 100644 index 0000000..ada8036 --- /dev/null +++ b/contests/Round#788/A/A.cpp @@ -0,0 +1,50 @@ +#include + +using namespace std; + +string solve(vector v) { + int p = 0; + int n = 0; + for(int i = 0; i < v.size(); i++) { + if(v[i] > 0) { + p++; + } + else{ + n++; + } + } + int loop = min(p, n); + int loop1 = loop; + for(int i = 0; i < v.size(); i++) { + if(v[i] > 0 && loop != 0) { + v[i] = -v[i]; + loop--; + } + } + loop = min(p, n); + for(int i = v.size() - 1; i > 0; i--) { + if(v[i] < 0 && loop1 != 0) { + v[i] = -v[i]; + loop1--; + } + } + if(is_sorted(v.begin(), v.end())) { + return "YES"; + } + return "NO"; +} + + +int main () { + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + vector v(n); + for(auto &x : v) { + cin >> x; + } + cout << solve(v) << endl; + } +} diff --git a/contests/Round#788/B.cpp b/contests/Round#788/B.cpp deleted file mode 100644 index 02b1493..0000000 --- a/contests/Round#788/B.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std; - -int main () { - -} diff --git a/contests/Round#788/B/B.cpp b/contests/Round#788/B/B.cpp new file mode 100644 index 0000000..02b1493 --- /dev/null +++ b/contests/Round#788/B/B.cpp @@ -0,0 +1,7 @@ +#include + +using namespace std; + +int main () { + +} diff --git a/contests/Round#788/C.cpp b/contests/Round#788/C.cpp deleted file mode 100644 index f7133e4..0000000 --- a/contests/Round#788/C.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std - -int main () { - -} diff --git a/contests/Round#788/C/C.cpp b/contests/Round#788/C/C.cpp new file mode 100644 index 0000000..f7133e4 --- /dev/null +++ b/contests/Round#788/C/C.cpp @@ -0,0 +1,7 @@ +#include + +using namespace std + +int main () { + +} diff --git a/contests/Round#788/D.cpp b/contests/Round#788/D.cpp deleted file mode 100644 index f7133e4..0000000 --- a/contests/Round#788/D.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std - -int main () { - -} diff --git a/contests/Round#788/D/D.cpp b/contests/Round#788/D/D.cpp new file mode 100644 index 0000000..f7133e4 --- /dev/null +++ b/contests/Round#788/D/D.cpp @@ -0,0 +1,7 @@ +#include + +using namespace std + +int main () { + +} diff --git a/contests/Round#788/E.cpp b/contests/Round#788/E.cpp deleted file mode 100644 index f7133e4..0000000 --- a/contests/Round#788/E.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std - -int main () { - -} diff --git a/contests/Round#788/E/E.cpp b/contests/Round#788/E/E.cpp new file mode 100644 index 0000000..f7133e4 --- /dev/null +++ b/contests/Round#788/E/E.cpp @@ -0,0 +1,7 @@ +#include + +using namespace std + +int main () { + +} diff --git a/contests/Round#788/F.cpp b/contests/Round#788/F.cpp deleted file mode 100644 index f7133e4..0000000 --- a/contests/Round#788/F.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std - -int main () { - -} diff --git a/contests/Round#788/F/F.cpp b/contests/Round#788/F/F.cpp new file mode 100644 index 0000000..f7133e4 --- /dev/null +++ b/contests/Round#788/F/F.cpp @@ -0,0 +1,7 @@ +#include + +using namespace std + +int main () { + +} diff --git a/contests/Round#790/10-10-2022(Div4)/B.cpp b/contests/Round#790/10-10-2022(Div4)/B.cpp deleted file mode 100644 index a9e3a04..0000000 --- a/contests/Round#790/10-10-2022(Div4)/B.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -using namespace std; - -int main () { - int tt; - cin >> tt; - while(tt--) { - int n, c; - int ans = 0; - cin >> n; - vector v(n); - for(int &x : v) { - cin >> x; - } - int mn = *min_element(v.begin(), v.end()); - for(int i = 0; i < v.size(); i++) { - if(v[i] != mn){ - ans += v[i] - mn; - } - } - cout << ans << endl; - } - -} diff --git a/contests/Round#790/10-10-2022(Div4)/B/B.cpp b/contests/Round#790/10-10-2022(Div4)/B/B.cpp new file mode 100644 index 0000000..a9e3a04 --- /dev/null +++ b/contests/Round#790/10-10-2022(Div4)/B/B.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main () { + int tt; + cin >> tt; + while(tt--) { + int n, c; + int ans = 0; + cin >> n; + vector v(n); + for(int &x : v) { + cin >> x; + } + int mn = *min_element(v.begin(), v.end()); + for(int i = 0; i < v.size(); i++) { + if(v[i] != mn){ + ans += v[i] - mn; + } + } + cout << ans << endl; + } + +} diff --git a/contests/Round#790/10-10-2022(Div4)/C.cpp b/contests/Round#790/10-10-2022(Div4)/C.cpp deleted file mode 100644 index 68eda3d..0000000 --- a/contests/Round#790/10-10-2022(Div4)/C.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -using namespace std; - -int main () { - int tt; - cin >> tt; - while(tt--) { - int n, m; - cin >> n >> m; - vector v(n); - vector ans; - for(auto &s : v) { - cin >> s; - } - for(int i = 0; i < v.size() - 1;i++) { - for(int j = i + 1;j < v.size();j++){ - int sum = 0; - for(int k = 0; k < v[i].size(); k++) { - sum+=abs(v[i][k] - v[j][k]); - } - ans.push_back(sum); - } - } - cout << *min_element(ans.begin(), ans.end()) << endl; - } - -} diff --git a/contests/Round#790/10-10-2022(Div4)/C/C.cpp b/contests/Round#790/10-10-2022(Div4)/C/C.cpp new file mode 100644 index 0000000..68eda3d --- /dev/null +++ b/contests/Round#790/10-10-2022(Div4)/C/C.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + +int main () { + int tt; + cin >> tt; + while(tt--) { + int n, m; + cin >> n >> m; + vector v(n); + vector ans; + for(auto &s : v) { + cin >> s; + } + for(int i = 0; i < v.size() - 1;i++) { + for(int j = i + 1;j < v.size();j++){ + int sum = 0; + for(int k = 0; k < v[i].size(); k++) { + sum+=abs(v[i][k] - v[j][k]); + } + ans.push_back(sum); + } + } + cout << *min_element(ans.begin(), ans.end()) << endl; + } + +} diff --git a/contests/Round#790/10-10-2022(Div4)/D.cpp b/contests/Round#790/10-10-2022(Div4)/D.cpp deleted file mode 100644 index 6ee775c..0000000 --- a/contests/Round#790/10-10-2022(Div4)/D.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include - -using namespace std; - -int main () { - int tt; - cin >> tt; - while(tt--) { - int r, c; - cin >> r >> c; - vector> grid(r, vector(c)); - for(auto &v : grid) { - for(auto &x : v){ - cin >> x; - } - } - vector res; - int ans = 0; - for(int i = 0; i < r; i++) { - for(int j = 0; j < c; j++) { - ans += grid[i][j]; - int r1 = i, r2 = i, r3 = i, r4 = i; - int c1 = j, c2 = j, c3 = j, c4 =j; - while(r1+1 <= r - 1 && c1 + 1 <= c - 1) { - r1++; - c1++; - ans+= grid[r1][c1]; - } - while(r2+1 <= r - 1 && c2 - 1 >= 0) { - r2++; - c2--; - ans+= grid[r2][c2]; - } - while(r3-1 >= 0 && c3 + 1 <= c - 1) { - r3--; - c3++; - ans+= grid[r3][c3]; - } - while(r4-1 >= 0 && c4 - 1 >= 0) { - r4--; - c4--; - ans+= grid[r4][c4]; - cout << "r4 " << r4 << " c4 " << c4 << endl; - } - res.push_back(ans); - ans = 0; - } - } - cout << *max_element(res.begin(), res.end()) << endl; - } -} diff --git a/contests/Round#790/10-10-2022(Div4)/D/D.cpp b/contests/Round#790/10-10-2022(Div4)/D/D.cpp new file mode 100644 index 0000000..6ee775c --- /dev/null +++ b/contests/Round#790/10-10-2022(Div4)/D/D.cpp @@ -0,0 +1,51 @@ +#include + +using namespace std; + +int main () { + int tt; + cin >> tt; + while(tt--) { + int r, c; + cin >> r >> c; + vector> grid(r, vector(c)); + for(auto &v : grid) { + for(auto &x : v){ + cin >> x; + } + } + vector res; + int ans = 0; + for(int i = 0; i < r; i++) { + for(int j = 0; j < c; j++) { + ans += grid[i][j]; + int r1 = i, r2 = i, r3 = i, r4 = i; + int c1 = j, c2 = j, c3 = j, c4 =j; + while(r1+1 <= r - 1 && c1 + 1 <= c - 1) { + r1++; + c1++; + ans+= grid[r1][c1]; + } + while(r2+1 <= r - 1 && c2 - 1 >= 0) { + r2++; + c2--; + ans+= grid[r2][c2]; + } + while(r3-1 >= 0 && c3 + 1 <= c - 1) { + r3--; + c3++; + ans+= grid[r3][c3]; + } + while(r4-1 >= 0 && c4 - 1 >= 0) { + r4--; + c4--; + ans+= grid[r4][c4]; + cout << "r4 " << r4 << " c4 " << c4 << endl; + } + res.push_back(ans); + ans = 0; + } + } + cout << *max_element(res.begin(), res.end()) << endl; + } +} -- cgit v1.2.3