제출 #1128969

#제출 시각아이디문제언어결과실행 시간메모리
1128969ivazivaBliskost (COI23_bliskost)C++20
100 / 100
148 ms13692 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("tune=native") #include <bits/stdc++.h> using namespace std; constexpr int MAXN = 1000001; constexpr int MOD = 26; int n, q; string s1, s2; int x[MAXN], y[MAXN]; inline int mod26(int value) { return (value % MOD + MOD) % MOD; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q >> s1 >> s2; y[1] = mod26(s2[0] - s1[0]); x[1] = y[1]; for (int i = 2; i <= n; ++i) { y[i] = mod26(s2[i - 1] - s1[i - 1]); x[i] = mod26(y[i] - x[i - 1]); } cout << (x[n - 1] == y[n] ? "da" : "ne") << '\n'; while (q--) { int pos; char c; cin >> pos >> c; if (pos == n) { s1[n - 1] = c; y[n] = mod26(s2[n - 1] - s1[n - 1]); } else { int delta = mod26(s1[pos - 1] - c); s1[pos - 1] = c; if ((n - 1 - pos) % 2 == 0) x[n - 1] = mod26(x[n - 1] + delta); else x[n - 1] = mod26(x[n - 1] - delta); } cout << (x[n - 1] == y[n] ? "da" : "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...