#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 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 |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 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 |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
10 ms |
5256 KB |
Output is correct |
32 |
Correct |
11 ms |
5260 KB |
Output is correct |
33 |
Correct |
10 ms |
5280 KB |
Output is correct |
34 |
Correct |
10 ms |
5312 KB |
Output is correct |
35 |
Correct |
11 ms |
5772 KB |
Output is correct |
36 |
Correct |
10 ms |
5676 KB |
Output is correct |
37 |
Correct |
9 ms |
5620 KB |
Output is correct |
38 |
Correct |
10 ms |
5276 KB |
Output is correct |
39 |
Correct |
10 ms |
5816 KB |
Output is correct |
40 |
Correct |
10 ms |
5612 KB |
Output is correct |
41 |
Correct |
9 ms |
5272 KB |
Output is correct |
42 |
Correct |
11 ms |
5260 KB |
Output is correct |
43 |
Correct |
10 ms |
5676 KB |
Output is correct |
44 |
Correct |
10 ms |
5548 KB |
Output is correct |
45 |
Correct |
11 ms |
5272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 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 |
14 ms |
1112 KB |
Output is correct |
17 |
Correct |
14 ms |
1020 KB |
Output is correct |
18 |
Correct |
12 ms |
1116 KB |
Output is correct |
19 |
Correct |
12 ms |
1112 KB |
Output is correct |
20 |
Correct |
12 ms |
984 KB |
Output is correct |
21 |
Correct |
12 ms |
1368 KB |
Output is correct |
22 |
Correct |
13 ms |
1112 KB |
Output is correct |
23 |
Correct |
12 ms |
1116 KB |
Output is correct |
24 |
Correct |
12 ms |
992 KB |
Output is correct |
25 |
Correct |
12 ms |
1088 KB |
Output is correct |
26 |
Correct |
12 ms |
1116 KB |
Output is correct |
27 |
Correct |
13 ms |
1116 KB |
Output is correct |
28 |
Correct |
13 ms |
1060 KB |
Output is correct |
29 |
Correct |
13 ms |
1116 KB |
Output is correct |
30 |
Correct |
15 ms |
1128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 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 |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
14 ms |
1112 KB |
Output is correct |
32 |
Correct |
14 ms |
1020 KB |
Output is correct |
33 |
Correct |
12 ms |
1116 KB |
Output is correct |
34 |
Correct |
12 ms |
1112 KB |
Output is correct |
35 |
Correct |
12 ms |
984 KB |
Output is correct |
36 |
Correct |
12 ms |
1368 KB |
Output is correct |
37 |
Correct |
13 ms |
1112 KB |
Output is correct |
38 |
Correct |
12 ms |
1116 KB |
Output is correct |
39 |
Correct |
12 ms |
992 KB |
Output is correct |
40 |
Correct |
12 ms |
1088 KB |
Output is correct |
41 |
Correct |
12 ms |
1116 KB |
Output is correct |
42 |
Correct |
13 ms |
1116 KB |
Output is correct |
43 |
Correct |
13 ms |
1060 KB |
Output is correct |
44 |
Correct |
13 ms |
1116 KB |
Output is correct |
45 |
Correct |
15 ms |
1128 KB |
Output is correct |
46 |
Correct |
540 ms |
1268 KB |
Output is correct |
47 |
Correct |
533 ms |
1104 KB |
Output is correct |
48 |
Correct |
526 ms |
1752 KB |
Output is correct |
49 |
Correct |
522 ms |
1488 KB |
Output is correct |
50 |
Correct |
537 ms |
1068 KB |
Output is correct |
51 |
Correct |
527 ms |
1108 KB |
Output is correct |
52 |
Correct |
540 ms |
1120 KB |
Output is correct |
53 |
Correct |
522 ms |
1216 KB |
Output is correct |
54 |
Correct |
539 ms |
1108 KB |
Output is correct |
55 |
Correct |
522 ms |
1544 KB |
Output is correct |
56 |
Correct |
519 ms |
1500 KB |
Output is correct |
57 |
Correct |
532 ms |
1068 KB |
Output is correct |
58 |
Correct |
529 ms |
1144 KB |
Output is correct |
59 |
Correct |
539 ms |
1508 KB |
Output is correct |
60 |
Correct |
529 ms |
1296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 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 |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
10 ms |
5256 KB |
Output is correct |
32 |
Correct |
11 ms |
5260 KB |
Output is correct |
33 |
Correct |
10 ms |
5280 KB |
Output is correct |
34 |
Correct |
10 ms |
5312 KB |
Output is correct |
35 |
Correct |
11 ms |
5772 KB |
Output is correct |
36 |
Correct |
10 ms |
5676 KB |
Output is correct |
37 |
Correct |
9 ms |
5620 KB |
Output is correct |
38 |
Correct |
10 ms |
5276 KB |
Output is correct |
39 |
Correct |
10 ms |
5816 KB |
Output is correct |
40 |
Correct |
10 ms |
5612 KB |
Output is correct |
41 |
Correct |
9 ms |
5272 KB |
Output is correct |
42 |
Correct |
11 ms |
5260 KB |
Output is correct |
43 |
Correct |
10 ms |
5676 KB |
Output is correct |
44 |
Correct |
10 ms |
5548 KB |
Output is correct |
45 |
Correct |
11 ms |
5272 KB |
Output is correct |
46 |
Correct |
14 ms |
1112 KB |
Output is correct |
47 |
Correct |
14 ms |
1020 KB |
Output is correct |
48 |
Correct |
12 ms |
1116 KB |
Output is correct |
49 |
Correct |
12 ms |
1112 KB |
Output is correct |
50 |
Correct |
12 ms |
984 KB |
Output is correct |
51 |
Correct |
12 ms |
1368 KB |
Output is correct |
52 |
Correct |
13 ms |
1112 KB |
Output is correct |
53 |
Correct |
12 ms |
1116 KB |
Output is correct |
54 |
Correct |
12 ms |
992 KB |
Output is correct |
55 |
Correct |
12 ms |
1088 KB |
Output is correct |
56 |
Correct |
12 ms |
1116 KB |
Output is correct |
57 |
Correct |
13 ms |
1116 KB |
Output is correct |
58 |
Correct |
13 ms |
1060 KB |
Output is correct |
59 |
Correct |
13 ms |
1116 KB |
Output is correct |
60 |
Correct |
15 ms |
1128 KB |
Output is correct |
61 |
Correct |
540 ms |
1268 KB |
Output is correct |
62 |
Correct |
533 ms |
1104 KB |
Output is correct |
63 |
Correct |
526 ms |
1752 KB |
Output is correct |
64 |
Correct |
522 ms |
1488 KB |
Output is correct |
65 |
Correct |
537 ms |
1068 KB |
Output is correct |
66 |
Correct |
527 ms |
1108 KB |
Output is correct |
67 |
Correct |
540 ms |
1120 KB |
Output is correct |
68 |
Correct |
522 ms |
1216 KB |
Output is correct |
69 |
Correct |
539 ms |
1108 KB |
Output is correct |
70 |
Correct |
522 ms |
1544 KB |
Output is correct |
71 |
Correct |
519 ms |
1500 KB |
Output is correct |
72 |
Correct |
532 ms |
1068 KB |
Output is correct |
73 |
Correct |
529 ms |
1144 KB |
Output is correct |
74 |
Correct |
539 ms |
1508 KB |
Output is correct |
75 |
Correct |
529 ms |
1296 KB |
Output is correct |
76 |
Execution timed out |
1006 ms |
5516 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |