제출 #835411

#제출 시각아이디문제언어결과실행 시간메모리
835411MetalPowerBliskost (COI23_bliskost)C++14
100 / 100
285 ms24292 KiB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e6 + 10;

int N, Q;
string s, t;

struct segtree{
	int st[MX << 1];

	void upd(int p, int v){
		for(p += MX, st[p] = v, p >>= 1; p > 0; p >>= 1) st[p] = st[p << 1] + st[p << 1|1];
	}

	int que(int l, int r){
		int res = 0;
		for(l += MX, r += MX + 1; l < r; l >>= 1, r >>= 1){
			if(l & 1) res += st[l++];
			if(r & 1) res += st[--r];
		}
		return res;
	}
} S;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> Q >> s >> t;

	for(int i = N - 1; i >= 0; i--){
		int x = ((int) t[i] - (int) s[i] + 26) % 26;
		if((N - 1 - i) & 1) S.upd(i, -x);
		else S.upd(i, x);
	}
	if(S.que(0, N - 1) % 26 == 0) cout << "da\n";
	else cout << "ne\n";
	for(int i = 0; i < Q; i++){
		int p; char c; cin >> p >> c; p--;
		int x = ((int) t[p] - (int) c + 26) % 26;
		if((N - p - 1) & 1) S.upd(p, -x);
		else S.upd(p, x);
		s[p] = c;
		if(S.que(0, N - 1) % 26 == 0) cout << "da\n";
		else cout << "ne\n";
	}
}
#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...