Submission #1309702

#TimeUsernameProblemLanguageResultExecution timeMemory
1309702quollcucumber`Bliskost (COI23_bliskost)C++20
0 / 100
1 ms568 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ int n, q; cin >> n >> q; string a, b; cin >> a >> b; if(n == 1) { // assert(1==2); if(a == b) { cout<<"da\n"; }else { cout<<"ne\n"; } for(int i = 0; i < q; i++) { int pos; char c; cin >> pos >> c; a[pos-1] = c; if(a == b) { cout<<"da\n"; }else { cout<<"ne\n"; } } }else if(n == 2) { // assert(1==2); bool works = false; for(int i = 0; i < 26; i++) { if(a[0] + i == b[0] && a[1] + i == b[1]) { works = true; } } if(works) { cout<<"da\n"; }else { cout<<"ne\n"; } for(int j = 0; j < q; j++) { int pos; char c; cin >> pos >> c; a[pos-1] = c; works = false; for(int i = 0; i < 26; i++) { if(a[0] + i == b[0] && a[1] + i == b[1]) { works = true; } } if(works) { cout<<"da\n"; }else { cout<<"ne\n"; } } }else { int dif = 0; for(int i = 0 ; i < n; i++) { a[i] = 'a' + ((a[i] - 'a') + dif) % 26; if(b[i] >= a[i]) { dif = b[i] - a[i]; }else { dif = 'z' - a[i] + 1 + b[i] - 'a'; } } dif = dif % 2; // int moda = 0, modb = 0; // for(char i : a) { // moda += i; // // moda%= 2; // } // for(char i : b) { // modb += i; // // modb %= 2; // } // moda = moda % 2; // modb = modb % 2; if(dif % 2 == 0) { cout<<"da\n"; }else { cout<<"ne\n"; } for(int i = 0; i < q; i++) { // assert(1 == 2); // int pos; // char c; // cin >> pos >> c; // if((a[pos-1] - 'a') % 2 != (c - 'a') % 2) { // moda = 1 ^ moda; // } // a[pos-1] = c; // if(moda == modb) { // cout<<"da\n"; // }else { // cout<<"ne\n"; // } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...