├── README.md └── codeforces ├── Div 2 ├── Codeforces Round #851 (Div. 2) │ ├── A - One and Two │ │ ├── A - One and Two(Asemhisham).cpp.cpp │ │ └── temp(Asemhisham).txt │ ├── B-Sum of Two Numbers │ │ └── temp(Asemhisham).txt │ ├── C-Matching Numbers │ │ └── temp(Asemhisham).txt │ ├── D-Moving Dots │ │ └── temp(Asemhisham).txt │ ├── E-Sum Over Zero │ │ └── temp(Asemhisham).txt │ └── F-XOR, Tree, and Queries │ │ └── temp(Asemhisham).txt └── New Text Document.txt ├── Div(1+2) └── New Text Document.txt ├── Div1 └── New Text Document.txt ├── Div3 └── New Text Document.txt ├── Div4 ├── Codeforces Round #849 (Div. 4) │ ├── A - Codeforces Checking │ │ └── A - Codeforces Checking(asemhisham).cpp.cpp │ ├── B. Following Directions │ │ └── B. Following Directions(asemhisham).cpp.cpp │ ├── C. Prepend and Append │ │ ├── C.Prepend And Append (PandaX).cpp │ │ └── temp(Asemhisham).txt │ ├── D.Distinct Split │ │ └── D.Distinct Split (PandaX).cpp │ ├── E. Negatives and Positives │ │ └── temp(Asemhisham).txt │ ├── F. Range Update Point Query │ │ └── temp(Asemhisham).txt │ ├── G1. Teleporters (Easy Version) │ │ └── temp(Asemhisham).txt │ └── G2. Teleporters (Hard Version) │ │ └── temp(Asemhisham).txt └── New Text Document.txt └── New Text Document.txt /README.md: -------------------------------------------------------------------------------- 1 | ## Codeforces contests 2 | 3 |

4 | 5 | ## Overview 6 | This repository shall contain all (almost all) of the codeforces rounds for Div1, Div2, Div3 and Div4 from 2023. 7 | 8 | You may find unsolved problems, which you can contribute and solve them of course. 9 | 10 | ## Contribution 11 | ***Who can contribute*** 12 | - You will add your own solution to an unsolved or already solved problems 13 | - You will edit README file and add better description, overview... etc to the repo. 14 | - You won't edit other people's solutions 15 | - You will report any issues or enhacements 16 | 17 | ***These steps to how to make a contribution to this Repo*** 18 | 19 | - Follow the same style in the repo 20 | 1. Fork the repo first 21 | 1. Follow the following guidelines: 22 | 1. Open the folder of the div difficulty like (Div4 ,Div3 ,Div2) 23 | 1. Open the folder of the problem like(A. Codeforces Checking) 24 | 1. Make a file of your solution and follow this pattern ` ().` 25 | - for example `A. Codeforces Checking (Asemhisham).cpp` 26 | 1. Put this line as a comment on the top of your file: ``// Author: `` 27 | 1. Try to write comments to explain your solution 28 | 1. Redundant solutions will be rejected 29 | 1. Create a pull request here after that 30 | 1. You are highly advised to have the same coding style in all your soluions. People will just know how the code will look by knowing it is your solution (Like `Asem` usually adds a lot of macros and `Abdullah` writes more C-like code) 31 | 32 |
33 | 34 | ## Rules 35 | 1-Don't push a solution during the contest 36 | 37 | 2-Don't push un-authored code (Code should be yours) 38 | 39 | 3-Any PR that doesn't follow the contribution guide won't be accepted 40 | 41 | 42 |
43 | ## for more understand you can watch this repo to understand how to contribute 44 | (https://github.com/7oSkaaa/LeetCode_DailyChallenge_2023/blob/main/README.md) 45 | -------------------------------------------------------------------------------- /codeforces/Div 2/Codeforces Round #851 (Div. 2)/A - One and Two/A - One and Two(Asemhisham).cpp.cpp: -------------------------------------------------------------------------------- 1 | //author Asemhisham 2 | 3 | #include 4 | using namespace std; 5 | #define ll long long 6 | #define int long long 7 | #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 8 | const int N=1e6+5; 9 | signed main() { 10 | fast 11 | 12 | ll t = 1; 13 | cin>>t; 14 | while (t--) { 15 | mapmp; 16 | int n;cin>>n; 17 | vectorv(n); 18 | for(int i=0;i> z; 20 | if (z == 2) 21 | mp[z]++; 22 | v[i]=mp[2]; 23 | } 24 | if(mp[2]&1){ 25 | cout<<"-1\n"; 26 | } 27 | 28 | else{ 29 | int x=mp[2]/2; 30 | for (int i = 0; i < n; ++i) { 31 | if(v[i]==x){ 32 | cout< 2 | using namespace std; 3 | #define ll long long 4 | #define int long long 5 | #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); \ 6 | 7 | signed main() { 8 | fast 9 | //freopen("popcorn.in","r",stdin); 10 | // freopen("output.txt","w", stdout); 11 | ll t = 1; 12 | cin>>t; 13 | mapmp; 14 | //codeforces 15 | 16 | mp['c']++; 17 | mp['o']++; 18 | mp['d']++; 19 | mp['e']++; 20 | mp['f']++; 21 | mp['o']++; 22 | mp['r']++; 23 | mp['c']++; 24 | mp['e']++; 25 | mp['s']++; 26 | 27 | while (t--) { 28 | char x;cin>>x; 29 | if(mp[x])cout<<"yes\n"; 30 | else cout<<"NO\n"; 31 | 32 | } 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/B. Following Directions/B. Following Directions(asemhisham).cpp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long 4 | #define int long long 5 | #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 6 | 7 | signed main() { 8 | fast 9 | 10 | ll t = 1; 11 | cin>>t; 12 | while (t--) { 13 | int x = 0, y = 0, n,f=0; 14 | string moves; 15 | cin >> n >> moves; 16 | for(auto& i : moves){ 17 | if(i == 'L') x--; 18 | else if(i == 'R') x++; 19 | else if(i == 'U') y++; 20 | else y--; 21 | if(x == 1 && y == 1){ 22 | cout << "YES\n"; 23 | f=1; 24 | break; 25 | } 26 | } 27 | if(!f) 28 | cout << "NO\n"; 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/C. Prepend and Append/C.Prepend And Append (PandaX).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define ll long long 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | 8 | int T = 1; 9 | cin >> T; 10 | while (T--) 11 | { 12 | int n; 13 | cin >> n; 14 | string s; 15 | cin >> s; 16 | int i = 0, j = n - 1; 17 | while (i < j && s[i] != s[j]) 18 | { 19 | i++, j--; 20 | } 21 | cout << n - i * 2 << "\n"; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/C. Prepend and Append/temp(Asemhisham).txt: -------------------------------------------------------------------------------- 1 | problem (c) no solution yet -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/D.Distinct Split/D.Distinct Split (PandaX).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define ll long long 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | 8 | int T = 1; 9 | cin >> T; 10 | while (T--) 11 | { 12 | int n; 13 | cin >> n; 14 | string s; 15 | cin >> s; 16 | // Could use linear array for O(1) calculations 17 | map first, second; 18 | first[s[0]]++; 19 | for (int i = 1; i < n; i++) 20 | { 21 | second[s[i]]++; 22 | } 23 | int ret = first.size() + second.size(); 24 | for (int i = 1; i < n; i++) 25 | { 26 | first[s[i]]++, second[s[i]]--; 27 | if (!second[s[i]]) 28 | second.erase(s[i]); 29 | ret = max(ret, first.size() + second.size()); 30 | } 31 | cout << ret << "\n"; 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/E. Negatives and Positives/temp(Asemhisham).txt: -------------------------------------------------------------------------------- 1 | problem (E) no solution yet -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/F. Range Update Point Query/temp(Asemhisham).txt: -------------------------------------------------------------------------------- 1 | problem (F) no solution yet -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/G1. Teleporters (Easy Version)/temp(Asemhisham).txt: -------------------------------------------------------------------------------- 1 | problem (G1) no solution yet -------------------------------------------------------------------------------- /codeforces/Div4/Codeforces Round #849 (Div. 4)/G2. Teleporters (Hard Version)/temp(Asemhisham).txt: -------------------------------------------------------------------------------- 1 | problem (G2) no solution yet -------------------------------------------------------------------------------- /codeforces/Div4/New Text Document.txt: -------------------------------------------------------------------------------- 1 | div4 folder 2 | -------------------------------------------------------------------------------- /codeforces/New Text Document.txt: -------------------------------------------------------------------------------- 1 | code forces 2 | --------------------------------------------------------------------------------