Submission #925667

#TimeUsernameProblemLanguageResultExecution timeMemory
925667AmrBliskost (COI23_bliskost)C++14
57 / 100
1006 ms5816 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
    ll res = 1;
    x = x; // % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res*x)  ; // % mod;
        y = y>>1;
        x = (x*x) ; // % mod;
    }
    return res;
}
ll n , q;
string a , aa , b;
void plu(int in , ll x)
{
    if(int(aa[in]+x)<=int('z')) aa[in] = char(aa[in]+x);
    else
    {
        aa[in] = char(aa[in]-26+x);
    }
}
// abc
// ced
string d[] = {"ne","da"};
bool cal()
{
    aa = a;

        for(int i = 0; i < n-1; i++)
        {
            ll x = b[i]-aa[i];
            if(x<0) x+=26;
            plu(i,x);
            plu(i+1,x);
          //  cout << x << " " << aa << endl;
        }

        if(aa[n-1]==b[n-1]) return 1; else return 0;
}
void solve()
{
    cin >> n >> q;
    cin >> a >> b;
    cout << d[cal()] << endl;
    while(q--)
    {
        ll x; char c; cin >> x; cin >> c;
        a[x-1] = c;
        //cout << a << b << endl;
        cout << d[cal()] << endl;
    }
}
int main(){
    //freopen("friday.in","r",stdin);
    //freopen("friday.out","w",stdout);
    fast;
    while(TT--)
        solve();

    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...