#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set ;
#define int long long
#define F first
#define S second
#define rep(i , j , n ) for(int i = j ;i < n; i++ )
#define FOR(i , n ) rep(i ,0 , n )
#define sz size()
#define pb push_back
#define all(x) x.begin() , x.end()
#define vi vector<int>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define cans cout<<ans<<endl;
#define forx(i, x) for(auto i : x)
#define fast
#define pii pair<int ,int >
#define endl "\n"
#define sp ' '
const int N = 300 ;
const int inf = 1e15 ;
//int rec(int a , int b , int c, int d ){
//if(a+b+c+d == 0 )
//return 1 ;
//int ans = 0 ;
//if( ((a%2)^(2 * ( b%2 ) ) ^( 3 * (c%2 ) ) ^(4 * ( d%2 ) )) == 0 ) {
//ans = 1 ;
//}
// if(a)ans += rec(0 , b , c , d ) ;
// if(b)ans += rec(a , 0 , c , d ) ;
// if(c)ans += rec(a , b , 0 , d ) ;
// if(d)ans += rec(a , b , c , 0 ) ;
// return ans ;
//
//}
main()
{
int n, q ;
cin>> n >> q ;
string s, s1 ;
cin>> s >> s1 ;
int a[n] ;
int a1[n] ;
FOR(i, n )a[i] = s[i] - 'a' ;
FOR(i, n )a1[i] = s1[i] - 'a' ;
FOR(i, n-1 )
{
if(a[i] != a1[i] )
{
int temp = (a1[i] + 26 ) - a[i] ;
a[i] += temp ;
a[i+1]+=temp ;
a[i]%=26 ;
a[i+1]%=26 ;
}
}
bool ok= 1;
FOR(i, n )
{
if(a[i]!=a1[i])ok = 0 ;
}
if(ok)cout<<"da\n";
else cout<<"ne\n" ;
while(q--)
{
int idx; char v ;
cin >> idx >> v ;
idx--;
s[idx] = v ;
// cout<<s<<endl<<s1;
FOR(i, n )a[i] = s[i] - 'a' ;
FOR(i, n )a1[i] = s1[i] - 'a' ;
FOR(i, n-1 )
{
if(a[i] != a1[i] )
{
int temp = (a1[i] + 26 ) - a[i] ;
a[i] += temp ;
a[i+1]+=temp ;
a[i]%=26 ;
a[i+1]%=26 ;
}
}
ok= 1;
FOR(i, n )
{
if(a[i]!=a1[i])ok = 0 ;
}
if(ok)cout<<"da\n";
else cout<<"ne\n" ;
}
return 0 ;
}
Compilation message
Main.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
39 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
592 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
592 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 |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
592 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 |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
45 ms |
18056 KB |
Output is correct |
32 |
Correct |
44 ms |
17980 KB |
Output is correct |
33 |
Correct |
50 ms |
17988 KB |
Output is correct |
34 |
Correct |
44 ms |
17996 KB |
Output is correct |
35 |
Correct |
54 ms |
18044 KB |
Output is correct |
36 |
Correct |
44 ms |
18152 KB |
Output is correct |
37 |
Correct |
51 ms |
17996 KB |
Output is correct |
38 |
Correct |
47 ms |
17984 KB |
Output is correct |
39 |
Correct |
44 ms |
17988 KB |
Output is correct |
40 |
Correct |
45 ms |
17992 KB |
Output is correct |
41 |
Correct |
52 ms |
18148 KB |
Output is correct |
42 |
Correct |
44 ms |
17988 KB |
Output is correct |
43 |
Correct |
44 ms |
18000 KB |
Output is correct |
44 |
Correct |
46 ms |
17992 KB |
Output is correct |
45 |
Correct |
62 ms |
17984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
592 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
132 ms |
1072 KB |
Output is correct |
17 |
Correct |
131 ms |
1104 KB |
Output is correct |
18 |
Correct |
129 ms |
1104 KB |
Output is correct |
19 |
Correct |
133 ms |
928 KB |
Output is correct |
20 |
Correct |
159 ms |
1424 KB |
Output is correct |
21 |
Correct |
146 ms |
1052 KB |
Output is correct |
22 |
Correct |
130 ms |
852 KB |
Output is correct |
23 |
Correct |
133 ms |
1084 KB |
Output is correct |
24 |
Correct |
133 ms |
968 KB |
Output is correct |
25 |
Correct |
129 ms |
1104 KB |
Output is correct |
26 |
Correct |
138 ms |
980 KB |
Output is correct |
27 |
Correct |
145 ms |
1360 KB |
Output is correct |
28 |
Correct |
131 ms |
1084 KB |
Output is correct |
29 |
Correct |
130 ms |
992 KB |
Output is correct |
30 |
Correct |
129 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
592 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 |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
132 ms |
1072 KB |
Output is correct |
32 |
Correct |
131 ms |
1104 KB |
Output is correct |
33 |
Correct |
129 ms |
1104 KB |
Output is correct |
34 |
Correct |
133 ms |
928 KB |
Output is correct |
35 |
Correct |
159 ms |
1424 KB |
Output is correct |
36 |
Correct |
146 ms |
1052 KB |
Output is correct |
37 |
Correct |
130 ms |
852 KB |
Output is correct |
38 |
Correct |
133 ms |
1084 KB |
Output is correct |
39 |
Correct |
133 ms |
968 KB |
Output is correct |
40 |
Correct |
129 ms |
1104 KB |
Output is correct |
41 |
Correct |
138 ms |
980 KB |
Output is correct |
42 |
Correct |
145 ms |
1360 KB |
Output is correct |
43 |
Correct |
131 ms |
1084 KB |
Output is correct |
44 |
Correct |
130 ms |
992 KB |
Output is correct |
45 |
Correct |
129 ms |
1108 KB |
Output is correct |
46 |
Correct |
973 ms |
1752 KB |
Output is correct |
47 |
Correct |
963 ms |
1408 KB |
Output is correct |
48 |
Correct |
940 ms |
1324 KB |
Output is correct |
49 |
Correct |
937 ms |
1592 KB |
Output is correct |
50 |
Correct |
961 ms |
1324 KB |
Output is correct |
51 |
Correct |
956 ms |
1072 KB |
Output is correct |
52 |
Correct |
968 ms |
1620 KB |
Output is correct |
53 |
Correct |
938 ms |
1548 KB |
Output is correct |
54 |
Correct |
953 ms |
1208 KB |
Output is correct |
55 |
Correct |
936 ms |
1340 KB |
Output is correct |
56 |
Correct |
931 ms |
1072 KB |
Output is correct |
57 |
Correct |
947 ms |
1492 KB |
Output is correct |
58 |
Correct |
951 ms |
1364 KB |
Output is correct |
59 |
Correct |
978 ms |
1364 KB |
Output is correct |
60 |
Correct |
957 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
592 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 |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
45 ms |
18056 KB |
Output is correct |
32 |
Correct |
44 ms |
17980 KB |
Output is correct |
33 |
Correct |
50 ms |
17988 KB |
Output is correct |
34 |
Correct |
44 ms |
17996 KB |
Output is correct |
35 |
Correct |
54 ms |
18044 KB |
Output is correct |
36 |
Correct |
44 ms |
18152 KB |
Output is correct |
37 |
Correct |
51 ms |
17996 KB |
Output is correct |
38 |
Correct |
47 ms |
17984 KB |
Output is correct |
39 |
Correct |
44 ms |
17988 KB |
Output is correct |
40 |
Correct |
45 ms |
17992 KB |
Output is correct |
41 |
Correct |
52 ms |
18148 KB |
Output is correct |
42 |
Correct |
44 ms |
17988 KB |
Output is correct |
43 |
Correct |
44 ms |
18000 KB |
Output is correct |
44 |
Correct |
46 ms |
17992 KB |
Output is correct |
45 |
Correct |
62 ms |
17984 KB |
Output is correct |
46 |
Correct |
132 ms |
1072 KB |
Output is correct |
47 |
Correct |
131 ms |
1104 KB |
Output is correct |
48 |
Correct |
129 ms |
1104 KB |
Output is correct |
49 |
Correct |
133 ms |
928 KB |
Output is correct |
50 |
Correct |
159 ms |
1424 KB |
Output is correct |
51 |
Correct |
146 ms |
1052 KB |
Output is correct |
52 |
Correct |
130 ms |
852 KB |
Output is correct |
53 |
Correct |
133 ms |
1084 KB |
Output is correct |
54 |
Correct |
133 ms |
968 KB |
Output is correct |
55 |
Correct |
129 ms |
1104 KB |
Output is correct |
56 |
Correct |
138 ms |
980 KB |
Output is correct |
57 |
Correct |
145 ms |
1360 KB |
Output is correct |
58 |
Correct |
131 ms |
1084 KB |
Output is correct |
59 |
Correct |
130 ms |
992 KB |
Output is correct |
60 |
Correct |
129 ms |
1108 KB |
Output is correct |
61 |
Correct |
973 ms |
1752 KB |
Output is correct |
62 |
Correct |
963 ms |
1408 KB |
Output is correct |
63 |
Correct |
940 ms |
1324 KB |
Output is correct |
64 |
Correct |
937 ms |
1592 KB |
Output is correct |
65 |
Correct |
961 ms |
1324 KB |
Output is correct |
66 |
Correct |
956 ms |
1072 KB |
Output is correct |
67 |
Correct |
968 ms |
1620 KB |
Output is correct |
68 |
Correct |
938 ms |
1548 KB |
Output is correct |
69 |
Correct |
953 ms |
1208 KB |
Output is correct |
70 |
Correct |
936 ms |
1340 KB |
Output is correct |
71 |
Correct |
931 ms |
1072 KB |
Output is correct |
72 |
Correct |
947 ms |
1492 KB |
Output is correct |
73 |
Correct |
951 ms |
1364 KB |
Output is correct |
74 |
Correct |
978 ms |
1364 KB |
Output is correct |
75 |
Correct |
957 ms |
1276 KB |
Output is correct |
76 |
Execution timed out |
1037 ms |
20296 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |