답안 #835411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835411 2023-08-23T14:14:11 Z MetalPower Bliskost (COI23_bliskost) C++14
100 / 100
285 ms 24292 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e6 + 10;

int N, Q;
string s, t;

struct segtree{
	int st[MX << 1];

	void upd(int p, int v){
		for(p += MX, st[p] = v, p >>= 1; p > 0; p >>= 1) st[p] = st[p << 1] + st[p << 1|1];
	}

	int que(int l, int r){
		int res = 0;
		for(l += MX, r += MX + 1; l < r; l >>= 1, r >>= 1){
			if(l & 1) res += st[l++];
			if(r & 1) res += st[--r];
		}
		return res;
	}
} S;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> Q >> s >> t;

	for(int i = N - 1; i >= 0; i--){
		int x = ((int) t[i] - (int) s[i] + 26) % 26;
		if((N - 1 - i) & 1) S.upd(i, -x);
		else S.upd(i, x);
	}
	if(S.que(0, N - 1) % 26 == 0) cout << "da\n";
	else cout << "ne\n";
	for(int i = 0; i < Q; i++){
		int p; char c; cin >> p >> c; p--;
		int x = ((int) t[p] - (int) c + 26) % 26;
		if((N - p - 1) & 1) S.upd(p, -x);
		else S.upd(p, x);
		s[p] = c;
		if(S.que(0, N - 1) % 26 == 0) cout << "da\n";
		else cout << "ne\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 43 ms 10140 KB Output is correct
32 Correct 48 ms 10180 KB Output is correct
33 Correct 39 ms 10108 KB Output is correct
34 Correct 39 ms 10200 KB Output is correct
35 Correct 39 ms 10164 KB Output is correct
36 Correct 39 ms 10488 KB Output is correct
37 Correct 40 ms 10600 KB Output is correct
38 Correct 39 ms 10228 KB Output is correct
39 Correct 39 ms 10560 KB Output is correct
40 Correct 43 ms 10572 KB Output is correct
41 Correct 40 ms 10148 KB Output is correct
42 Correct 39 ms 10128 KB Output is correct
43 Correct 40 ms 10504 KB Output is correct
44 Correct 39 ms 10132 KB Output is correct
45 Correct 40 ms 10128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 12 ms 664 KB Output is correct
17 Correct 12 ms 980 KB Output is correct
18 Correct 14 ms 1024 KB Output is correct
19 Correct 13 ms 980 KB Output is correct
20 Correct 12 ms 980 KB Output is correct
21 Correct 12 ms 1064 KB Output is correct
22 Correct 12 ms 980 KB Output is correct
23 Correct 12 ms 1036 KB Output is correct
24 Correct 12 ms 984 KB Output is correct
25 Correct 12 ms 1024 KB Output is correct
26 Correct 12 ms 980 KB Output is correct
27 Correct 12 ms 980 KB Output is correct
28 Correct 12 ms 976 KB Output is correct
29 Correct 12 ms 1056 KB Output is correct
30 Correct 12 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 12 ms 664 KB Output is correct
32 Correct 12 ms 980 KB Output is correct
33 Correct 14 ms 1024 KB Output is correct
34 Correct 13 ms 980 KB Output is correct
35 Correct 12 ms 980 KB Output is correct
36 Correct 12 ms 1064 KB Output is correct
37 Correct 12 ms 980 KB Output is correct
38 Correct 12 ms 1036 KB Output is correct
39 Correct 12 ms 984 KB Output is correct
40 Correct 12 ms 1024 KB Output is correct
41 Correct 12 ms 980 KB Output is correct
42 Correct 12 ms 980 KB Output is correct
43 Correct 12 ms 976 KB Output is correct
44 Correct 12 ms 1056 KB Output is correct
45 Correct 12 ms 1044 KB Output is correct
46 Correct 16 ms 1236 KB Output is correct
47 Correct 14 ms 1236 KB Output is correct
48 Correct 15 ms 1184 KB Output is correct
49 Correct 15 ms 1208 KB Output is correct
50 Correct 14 ms 1220 KB Output is correct
51 Correct 14 ms 1180 KB Output is correct
52 Correct 14 ms 1236 KB Output is correct
53 Correct 19 ms 1236 KB Output is correct
54 Correct 15 ms 1272 KB Output is correct
55 Correct 15 ms 1236 KB Output is correct
56 Correct 14 ms 1184 KB Output is correct
57 Correct 14 ms 1236 KB Output is correct
58 Correct 14 ms 1228 KB Output is correct
59 Correct 14 ms 1236 KB Output is correct
60 Correct 14 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 43 ms 10140 KB Output is correct
32 Correct 48 ms 10180 KB Output is correct
33 Correct 39 ms 10108 KB Output is correct
34 Correct 39 ms 10200 KB Output is correct
35 Correct 39 ms 10164 KB Output is correct
36 Correct 39 ms 10488 KB Output is correct
37 Correct 40 ms 10600 KB Output is correct
38 Correct 39 ms 10228 KB Output is correct
39 Correct 39 ms 10560 KB Output is correct
40 Correct 43 ms 10572 KB Output is correct
41 Correct 40 ms 10148 KB Output is correct
42 Correct 39 ms 10128 KB Output is correct
43 Correct 40 ms 10504 KB Output is correct
44 Correct 39 ms 10132 KB Output is correct
45 Correct 40 ms 10128 KB Output is correct
46 Correct 12 ms 664 KB Output is correct
47 Correct 12 ms 980 KB Output is correct
48 Correct 14 ms 1024 KB Output is correct
49 Correct 13 ms 980 KB Output is correct
50 Correct 12 ms 980 KB Output is correct
51 Correct 12 ms 1064 KB Output is correct
52 Correct 12 ms 980 KB Output is correct
53 Correct 12 ms 1036 KB Output is correct
54 Correct 12 ms 984 KB Output is correct
55 Correct 12 ms 1024 KB Output is correct
56 Correct 12 ms 980 KB Output is correct
57 Correct 12 ms 980 KB Output is correct
58 Correct 12 ms 976 KB Output is correct
59 Correct 12 ms 1056 KB Output is correct
60 Correct 12 ms 1044 KB Output is correct
61 Correct 16 ms 1236 KB Output is correct
62 Correct 14 ms 1236 KB Output is correct
63 Correct 15 ms 1184 KB Output is correct
64 Correct 15 ms 1208 KB Output is correct
65 Correct 14 ms 1220 KB Output is correct
66 Correct 14 ms 1180 KB Output is correct
67 Correct 14 ms 1236 KB Output is correct
68 Correct 19 ms 1236 KB Output is correct
69 Correct 15 ms 1272 KB Output is correct
70 Correct 15 ms 1236 KB Output is correct
71 Correct 14 ms 1184 KB Output is correct
72 Correct 14 ms 1236 KB Output is correct
73 Correct 14 ms 1228 KB Output is correct
74 Correct 14 ms 1236 KB Output is correct
75 Correct 14 ms 1236 KB Output is correct
76 Correct 262 ms 23892 KB Output is correct
77 Correct 280 ms 24180 KB Output is correct
78 Correct 267 ms 23864 KB Output is correct
79 Correct 269 ms 23956 KB Output is correct
80 Correct 276 ms 24108 KB Output is correct
81 Correct 254 ms 23876 KB Output is correct
82 Correct 284 ms 23864 KB Output is correct
83 Correct 271 ms 23792 KB Output is correct
84 Correct 275 ms 23832 KB Output is correct
85 Correct 258 ms 23880 KB Output is correct
86 Correct 249 ms 24164 KB Output is correct
87 Correct 244 ms 24232 KB Output is correct
88 Correct 285 ms 24292 KB Output is correct
89 Correct 264 ms 23892 KB Output is correct
90 Correct 269 ms 24192 KB Output is correct