#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ldb,ldb> pdd;
#define ff(i,a,b) for(int i = a; i <= b; i++)
#define fb(i,b,a) for(int i = b; i >= a; i--)
#define trav(a,x) for(auto& a : x)
#define sz(a) (int)(a).size()
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k) print the k-th smallest number in os(0-based)
const int mod = 1000000007;
const int inf = 1e9 + 5;
const int mxN = 1000005;
int n, q;
string s, t;
int d[mxN];
int r[mxN];
bool check(int a, int b){
int x = abs(a) % 26;
if(a < 0)a = 26 - x;
else a = x;
a %= 26;
int y = abs(b) % 26;
if(b < 0)b = 26 - y;
else b = y;
b %= 26;
return (a == b);
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> q >> s >> t;
s = ' ' + s; t = ' ' + t;
ff(i,1,n){
r[i] = s[i] - t[i];
d[i + 1] = r[i] - d[i];
}
cout << (check(d[n], r[n]) ? "da" : "ne") << '\n';
while(q--){
int pos; char c;
cin >> pos >> c;
s[pos] = c;
int nw = s[pos] - t[pos];
int diff = nw - r[pos];
r[pos] = nw;
if(pos != n){
if((n - 1) % 2 == pos % 2)d[n] += diff;
else d[n] -= diff;
}
cout << (check(d[n], r[n]) ? "da" : "ne") << '\n';
}
return 0;
}
/*
3 1
bbc
ced
1 a
6 0
berlio
pjesni
// probati bojenje sahovski
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
360 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
360 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
7 ms |
10220 KB |
Output is correct |
32 |
Correct |
6 ms |
10216 KB |
Output is correct |
33 |
Correct |
7 ms |
10228 KB |
Output is correct |
34 |
Correct |
6 ms |
10228 KB |
Output is correct |
35 |
Correct |
6 ms |
10212 KB |
Output is correct |
36 |
Correct |
6 ms |
10068 KB |
Output is correct |
37 |
Correct |
7 ms |
10068 KB |
Output is correct |
38 |
Correct |
7 ms |
10228 KB |
Output is correct |
39 |
Correct |
7 ms |
10072 KB |
Output is correct |
40 |
Correct |
6 ms |
10060 KB |
Output is correct |
41 |
Correct |
6 ms |
10132 KB |
Output is correct |
42 |
Correct |
6 ms |
10212 KB |
Output is correct |
43 |
Correct |
6 ms |
10072 KB |
Output is correct |
44 |
Correct |
7 ms |
10160 KB |
Output is correct |
45 |
Correct |
7 ms |
10224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
11 ms |
600 KB |
Output is correct |
17 |
Correct |
11 ms |
856 KB |
Output is correct |
18 |
Correct |
11 ms |
604 KB |
Output is correct |
19 |
Correct |
11 ms |
604 KB |
Output is correct |
20 |
Correct |
11 ms |
604 KB |
Output is correct |
21 |
Correct |
10 ms |
604 KB |
Output is correct |
22 |
Correct |
14 ms |
604 KB |
Output is correct |
23 |
Correct |
11 ms |
748 KB |
Output is correct |
24 |
Correct |
11 ms |
604 KB |
Output is correct |
25 |
Correct |
11 ms |
604 KB |
Output is correct |
26 |
Correct |
11 ms |
604 KB |
Output is correct |
27 |
Correct |
11 ms |
748 KB |
Output is correct |
28 |
Correct |
10 ms |
604 KB |
Output is correct |
29 |
Correct |
11 ms |
592 KB |
Output is correct |
30 |
Correct |
11 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
360 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
11 ms |
600 KB |
Output is correct |
32 |
Correct |
11 ms |
856 KB |
Output is correct |
33 |
Correct |
11 ms |
604 KB |
Output is correct |
34 |
Correct |
11 ms |
604 KB |
Output is correct |
35 |
Correct |
11 ms |
604 KB |
Output is correct |
36 |
Correct |
10 ms |
604 KB |
Output is correct |
37 |
Correct |
14 ms |
604 KB |
Output is correct |
38 |
Correct |
11 ms |
748 KB |
Output is correct |
39 |
Correct |
11 ms |
604 KB |
Output is correct |
40 |
Correct |
11 ms |
604 KB |
Output is correct |
41 |
Correct |
11 ms |
604 KB |
Output is correct |
42 |
Correct |
11 ms |
748 KB |
Output is correct |
43 |
Correct |
10 ms |
604 KB |
Output is correct |
44 |
Correct |
11 ms |
592 KB |
Output is correct |
45 |
Correct |
11 ms |
604 KB |
Output is correct |
46 |
Correct |
11 ms |
856 KB |
Output is correct |
47 |
Correct |
12 ms |
856 KB |
Output is correct |
48 |
Correct |
12 ms |
600 KB |
Output is correct |
49 |
Correct |
12 ms |
604 KB |
Output is correct |
50 |
Correct |
12 ms |
756 KB |
Output is correct |
51 |
Correct |
12 ms |
604 KB |
Output is correct |
52 |
Correct |
12 ms |
600 KB |
Output is correct |
53 |
Correct |
12 ms |
600 KB |
Output is correct |
54 |
Correct |
13 ms |
792 KB |
Output is correct |
55 |
Correct |
12 ms |
604 KB |
Output is correct |
56 |
Correct |
12 ms |
604 KB |
Output is correct |
57 |
Correct |
11 ms |
604 KB |
Output is correct |
58 |
Correct |
11 ms |
604 KB |
Output is correct |
59 |
Correct |
12 ms |
604 KB |
Output is correct |
60 |
Correct |
11 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
360 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
7 ms |
10220 KB |
Output is correct |
32 |
Correct |
6 ms |
10216 KB |
Output is correct |
33 |
Correct |
7 ms |
10228 KB |
Output is correct |
34 |
Correct |
6 ms |
10228 KB |
Output is correct |
35 |
Correct |
6 ms |
10212 KB |
Output is correct |
36 |
Correct |
6 ms |
10068 KB |
Output is correct |
37 |
Correct |
7 ms |
10068 KB |
Output is correct |
38 |
Correct |
7 ms |
10228 KB |
Output is correct |
39 |
Correct |
7 ms |
10072 KB |
Output is correct |
40 |
Correct |
6 ms |
10060 KB |
Output is correct |
41 |
Correct |
6 ms |
10132 KB |
Output is correct |
42 |
Correct |
6 ms |
10212 KB |
Output is correct |
43 |
Correct |
6 ms |
10072 KB |
Output is correct |
44 |
Correct |
7 ms |
10160 KB |
Output is correct |
45 |
Correct |
7 ms |
10224 KB |
Output is correct |
46 |
Correct |
11 ms |
600 KB |
Output is correct |
47 |
Correct |
11 ms |
856 KB |
Output is correct |
48 |
Correct |
11 ms |
604 KB |
Output is correct |
49 |
Correct |
11 ms |
604 KB |
Output is correct |
50 |
Correct |
11 ms |
604 KB |
Output is correct |
51 |
Correct |
10 ms |
604 KB |
Output is correct |
52 |
Correct |
14 ms |
604 KB |
Output is correct |
53 |
Correct |
11 ms |
748 KB |
Output is correct |
54 |
Correct |
11 ms |
604 KB |
Output is correct |
55 |
Correct |
11 ms |
604 KB |
Output is correct |
56 |
Correct |
11 ms |
604 KB |
Output is correct |
57 |
Correct |
11 ms |
748 KB |
Output is correct |
58 |
Correct |
10 ms |
604 KB |
Output is correct |
59 |
Correct |
11 ms |
592 KB |
Output is correct |
60 |
Correct |
11 ms |
604 KB |
Output is correct |
61 |
Correct |
11 ms |
856 KB |
Output is correct |
62 |
Correct |
12 ms |
856 KB |
Output is correct |
63 |
Correct |
12 ms |
600 KB |
Output is correct |
64 |
Correct |
12 ms |
604 KB |
Output is correct |
65 |
Correct |
12 ms |
756 KB |
Output is correct |
66 |
Correct |
12 ms |
604 KB |
Output is correct |
67 |
Correct |
12 ms |
600 KB |
Output is correct |
68 |
Correct |
12 ms |
600 KB |
Output is correct |
69 |
Correct |
13 ms |
792 KB |
Output is correct |
70 |
Correct |
12 ms |
604 KB |
Output is correct |
71 |
Correct |
12 ms |
604 KB |
Output is correct |
72 |
Correct |
11 ms |
604 KB |
Output is correct |
73 |
Correct |
11 ms |
604 KB |
Output is correct |
74 |
Correct |
12 ms |
604 KB |
Output is correct |
75 |
Correct |
11 ms |
604 KB |
Output is correct |
76 |
Correct |
147 ms |
21720 KB |
Output is correct |
77 |
Correct |
140 ms |
23696 KB |
Output is correct |
78 |
Correct |
171 ms |
23696 KB |
Output is correct |
79 |
Correct |
150 ms |
23828 KB |
Output is correct |
80 |
Correct |
150 ms |
24060 KB |
Output is correct |
81 |
Correct |
141 ms |
23720 KB |
Output is correct |
82 |
Correct |
145 ms |
23776 KB |
Output is correct |
83 |
Correct |
139 ms |
23776 KB |
Output is correct |
84 |
Correct |
135 ms |
23764 KB |
Output is correct |
85 |
Correct |
137 ms |
23760 KB |
Output is correct |
86 |
Correct |
141 ms |
23876 KB |
Output is correct |
87 |
Correct |
166 ms |
23912 KB |
Output is correct |
88 |
Correct |
138 ms |
23804 KB |
Output is correct |
89 |
Correct |
150 ms |
23728 KB |
Output is correct |
90 |
Correct |
142 ms |
23768 KB |
Output is correct |