#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define a2b(a, b) (a << b) // a*2^b
#define bit(a, b) ((a >> b) & 1) // bth bit from the right, starts at zero
using namespace std;
template<class T> using vec = vector<T>;
const int INFTY = (1LL << 63) - 1;
const int NNFTY = 1LL << 63;
template<typename T, typename U> inline T nmod(T a, U b) {
T r = a % b; if (r < 0) r += b; return r;
}
bool sim(string s1, string s2) {
int n = s1.size();
if (n != s2.size()) return false;
int lastdiff = 0;
for (int i = 0; i < n - 1; i++) {
lastdiff = nmod(s1[i] - s2[i] - lastdiff, 26LL);
if (i == n - 2 && lastdiff != nmod(s1[n - 1] - s2[n - 1], 26)) return false;
}
return true;
}
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, q; cin >> n >> q;
string s1, s2; cin >> s1 >> s2;
cout << "ne\n\0da\n" + 4*sim(s1, s2);
while (q--) {
int i; char c; cin >> i >> c; i--;
s1[i] = c;
cout << "ne\n\0da\n" + 4*sim(s1, s2);
}
}
Compilation message
Main.cpp:9:31: warning: integer overflow in expression of type 'long long int' results in '9223372036854775807' [-Woverflow]
9 | const int INFTY = (1LL << 63) - 1;
| ~~~~~~~~~~~~^~~
Main.cpp: In function 'bool sim(std::string, std::string)':
Main.cpp:18:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | if (n != s2.size()) return false;
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
500 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
500 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
10 ms |
4480 KB |
Output is correct |
32 |
Correct |
10 ms |
4480 KB |
Output is correct |
33 |
Correct |
10 ms |
4508 KB |
Output is correct |
34 |
Correct |
10 ms |
4496 KB |
Output is correct |
35 |
Correct |
9 ms |
4480 KB |
Output is correct |
36 |
Correct |
10 ms |
4840 KB |
Output is correct |
37 |
Correct |
10 ms |
4884 KB |
Output is correct |
38 |
Correct |
10 ms |
4664 KB |
Output is correct |
39 |
Correct |
10 ms |
4844 KB |
Output is correct |
40 |
Correct |
10 ms |
4832 KB |
Output is correct |
41 |
Correct |
10 ms |
4520 KB |
Output is correct |
42 |
Correct |
10 ms |
4480 KB |
Output is correct |
43 |
Correct |
10 ms |
4880 KB |
Output is correct |
44 |
Correct |
10 ms |
4512 KB |
Output is correct |
45 |
Correct |
10 ms |
4660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
592 KB |
Output is correct |
17 |
Correct |
9 ms |
592 KB |
Output is correct |
18 |
Correct |
10 ms |
592 KB |
Output is correct |
19 |
Correct |
10 ms |
592 KB |
Output is correct |
20 |
Correct |
9 ms |
592 KB |
Output is correct |
21 |
Correct |
9 ms |
592 KB |
Output is correct |
22 |
Correct |
13 ms |
592 KB |
Output is correct |
23 |
Correct |
10 ms |
592 KB |
Output is correct |
24 |
Correct |
10 ms |
592 KB |
Output is correct |
25 |
Correct |
10 ms |
592 KB |
Output is correct |
26 |
Correct |
12 ms |
592 KB |
Output is correct |
27 |
Correct |
9 ms |
592 KB |
Output is correct |
28 |
Correct |
10 ms |
592 KB |
Output is correct |
29 |
Correct |
10 ms |
592 KB |
Output is correct |
30 |
Correct |
10 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
500 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
9 ms |
592 KB |
Output is correct |
32 |
Correct |
9 ms |
592 KB |
Output is correct |
33 |
Correct |
10 ms |
592 KB |
Output is correct |
34 |
Correct |
10 ms |
592 KB |
Output is correct |
35 |
Correct |
9 ms |
592 KB |
Output is correct |
36 |
Correct |
9 ms |
592 KB |
Output is correct |
37 |
Correct |
13 ms |
592 KB |
Output is correct |
38 |
Correct |
10 ms |
592 KB |
Output is correct |
39 |
Correct |
10 ms |
592 KB |
Output is correct |
40 |
Correct |
10 ms |
592 KB |
Output is correct |
41 |
Correct |
12 ms |
592 KB |
Output is correct |
42 |
Correct |
9 ms |
592 KB |
Output is correct |
43 |
Correct |
10 ms |
592 KB |
Output is correct |
44 |
Correct |
10 ms |
592 KB |
Output is correct |
45 |
Correct |
10 ms |
592 KB |
Output is correct |
46 |
Correct |
439 ms |
584 KB |
Output is correct |
47 |
Correct |
433 ms |
584 KB |
Output is correct |
48 |
Correct |
425 ms |
736 KB |
Output is correct |
49 |
Correct |
425 ms |
584 KB |
Output is correct |
50 |
Correct |
436 ms |
728 KB |
Output is correct |
51 |
Correct |
431 ms |
748 KB |
Output is correct |
52 |
Correct |
437 ms |
584 KB |
Output is correct |
53 |
Correct |
422 ms |
740 KB |
Output is correct |
54 |
Correct |
430 ms |
752 KB |
Output is correct |
55 |
Correct |
424 ms |
584 KB |
Output is correct |
56 |
Correct |
420 ms |
716 KB |
Output is correct |
57 |
Correct |
429 ms |
548 KB |
Output is correct |
58 |
Correct |
428 ms |
636 KB |
Output is correct |
59 |
Correct |
436 ms |
584 KB |
Output is correct |
60 |
Correct |
438 ms |
720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
500 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
10 ms |
4480 KB |
Output is correct |
32 |
Correct |
10 ms |
4480 KB |
Output is correct |
33 |
Correct |
10 ms |
4508 KB |
Output is correct |
34 |
Correct |
10 ms |
4496 KB |
Output is correct |
35 |
Correct |
9 ms |
4480 KB |
Output is correct |
36 |
Correct |
10 ms |
4840 KB |
Output is correct |
37 |
Correct |
10 ms |
4884 KB |
Output is correct |
38 |
Correct |
10 ms |
4664 KB |
Output is correct |
39 |
Correct |
10 ms |
4844 KB |
Output is correct |
40 |
Correct |
10 ms |
4832 KB |
Output is correct |
41 |
Correct |
10 ms |
4520 KB |
Output is correct |
42 |
Correct |
10 ms |
4480 KB |
Output is correct |
43 |
Correct |
10 ms |
4880 KB |
Output is correct |
44 |
Correct |
10 ms |
4512 KB |
Output is correct |
45 |
Correct |
10 ms |
4660 KB |
Output is correct |
46 |
Correct |
9 ms |
592 KB |
Output is correct |
47 |
Correct |
9 ms |
592 KB |
Output is correct |
48 |
Correct |
10 ms |
592 KB |
Output is correct |
49 |
Correct |
10 ms |
592 KB |
Output is correct |
50 |
Correct |
9 ms |
592 KB |
Output is correct |
51 |
Correct |
9 ms |
592 KB |
Output is correct |
52 |
Correct |
13 ms |
592 KB |
Output is correct |
53 |
Correct |
10 ms |
592 KB |
Output is correct |
54 |
Correct |
10 ms |
592 KB |
Output is correct |
55 |
Correct |
10 ms |
592 KB |
Output is correct |
56 |
Correct |
12 ms |
592 KB |
Output is correct |
57 |
Correct |
9 ms |
592 KB |
Output is correct |
58 |
Correct |
10 ms |
592 KB |
Output is correct |
59 |
Correct |
10 ms |
592 KB |
Output is correct |
60 |
Correct |
10 ms |
592 KB |
Output is correct |
61 |
Correct |
439 ms |
584 KB |
Output is correct |
62 |
Correct |
433 ms |
584 KB |
Output is correct |
63 |
Correct |
425 ms |
736 KB |
Output is correct |
64 |
Correct |
425 ms |
584 KB |
Output is correct |
65 |
Correct |
436 ms |
728 KB |
Output is correct |
66 |
Correct |
431 ms |
748 KB |
Output is correct |
67 |
Correct |
437 ms |
584 KB |
Output is correct |
68 |
Correct |
422 ms |
740 KB |
Output is correct |
69 |
Correct |
430 ms |
752 KB |
Output is correct |
70 |
Correct |
424 ms |
584 KB |
Output is correct |
71 |
Correct |
420 ms |
716 KB |
Output is correct |
72 |
Correct |
429 ms |
548 KB |
Output is correct |
73 |
Correct |
428 ms |
636 KB |
Output is correct |
74 |
Correct |
436 ms |
584 KB |
Output is correct |
75 |
Correct |
438 ms |
720 KB |
Output is correct |
76 |
Execution timed out |
1036 ms |
4484 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |