This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define int long long
#define nl '\n'
#define pb push_back
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n , q;
cin>>n>>q;
string s , t;
cin>>s>>t;
s = '.' + s;
t = '.' + t;
vector<int> a(n);
a[0] = 0;
for(int i = 1 ; i <= n - 1 ; i++)
{
a[i] = (t[i] - s[i] - a[i - 1] + 2 * 26)%26;
}
if(a[n - 1] == (t[n] - s[n] + 26)%26)
cout<<"da"<<nl;
else
cout<<"ne"<<nl;
while(q--)
{
int i;
char c;
cin>>i>>c;
int diff = (s[i] - c + 26)%26;
s[i] = c;
int j = n - 1;
if(j >= i)
{
if((j - i)%2 == 0)
{
a[j] = (a[j] + diff)%26;
}
else
{
a[j] = (a[j] - diff + 26)%26;
}
}
if(a[n - 1] == (t[n] - s[n] + 26)%26)
cout<<"da"<<nl;
else
cout<<"ne"<<nl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |