Submission #711200

# Submission time Handle Problem Language Result Execution time Memory
711200 2023-03-16T09:46:13 Z Antekb Crossing (JOI21_crossing) C++17
100 / 100
1010 ms 35148 KB
#include<bits/stdc++.h>

#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pp pop_back
#define all(x) (x).begin(), (x).end();

using namespace std;

void debug(){cerr<<"\n";}
template<typename H, typename... T>
void debug(H h, T... t){
	cerr<<h;
	if(sizeof...(t))cerr<<", ";
	debug(t...);
}
#define deb(x...) cerr<<#x<<" = ";debug(x);

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N=1<<18;
vector<vi> dobre;
int cod[256];
int czy[N+N][9], lazy[N+N];
bool czy2[N+N][9];
void conv(int i, int j){
	dobre.pb({});
	for(int a=0; a<dobre[0].size(); a++){
		dobre.back().eb((6-dobre[i][a]-dobre[j][a])%3);
	}
}
void create(){
	for(int i=0; i<9; i++){
		for(int j=0; j<dobre[i].size(); j++){
			czy[N+j][i]=dobre[i][j];
		}
		for(int j=N-1; j>0; j--){
			if(czy[j+j][i]==czy[j+j+1][i])czy[j][i]=czy[j+j][i];
			else czy[j][i]=-1;
		}
		for(int j=0; j<N+N; j++)czy2[j][i]=1, lazy[j]=-1;
	}
}
void prop(int v){
	if(lazy[v]==-1 || v>=N)return;
	int l=v+v, r=l+1;
	lazy[l]=lazy[r]=lazy[v];
	for(int i=0; i<9; i++){
		czy2[l][i]=(lazy[v]==czy[l][i]);
		czy2[r][i]=(lazy[v]==czy[r][i]);
	}
	lazy[v]=-1;
}
void ust(int v, int L, int R, int l, int r, int c){
	if(l==L && r==R){
		lazy[v]=c;
		for(int i=0; i<9; i++){
			czy2[v][i]=(lazy[v]==czy[v][i]);
		}
		return;
	}
	int M=(L+R)>>1;
	prop(v);
	if(l<=M)ust(v+v, L, M, l, min(r, M), c);
	if(r>M)ust(v+v+1, M+1, R, max(l, M+1), r, c);
	for(int i=0; i<9; i++){
		czy2[v][i]=czy2[v+v][i]&czy2[v+v+1][i];
	}
}
void ask(){
	bool b=0;
	for(int i=0;i<9; i++){
		if(czy2[1][i])b=1;
	}
	if(b)cout<<"Yes\n";
	else cout<<"No\n";
}
void out(int i){
	assert(N<30);
	for(int j=0; j<N+N; j++){
		deb(j, i, czy[j][i], czy2[j][i], lazy[j]);
	}
}
int main(){
	//ios_base::sync_with_stdio(0);cin.tie(0);
	cod['O']=0;
	cod['I']=1;
	cod['J']=2;
	int n;
	cin>>n;
	string s;
	for(int i=0; i<3; i++){
		cin>>s;
		dobre.pb({});
		for(char c:s)dobre.back().pb(cod[c]);
	}
	for(int i=0; i<2; i++){
		conv(3*i, 3*i+1);
		conv(3*i, 3*i+2);
		conv(3*i+1, 3*i+2);
	}
	//for(vi i:dobre){for(int j:i)cout<<j<<" ";cout<<"\n";}
	int q;
	cin>>q;
	cin>>s;
	create();
	//out(5);
	for(int i=0; i<n; i++)ust(1, 0, N-1, i, i, cod[s[i]]);
	//out(5);
	ask();
	while(q--){
		int l, r;
		char c;
		cin>>l>>r>>c;
		l--, r--;
		ust(1, 0, N-1, l, r, cod[c]);
		ask();
	}
}

Compilation message

Main.cpp: In function 'void conv(int, int)':
Main.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int a=0; a<dobre[0].size(); a++){
      |               ~^~~~~~~~~~~~~~~~
Main.cpp: In function 'void create()':
Main.cpp:41:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(int j=0; j<dobre[i].size(); j++){
      |                ~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:102:36: warning: array subscript has type 'char' [-Wchar-subscripts]
  102 |   for(char c:s)dobre.back().pb(cod[c]);
      |                                    ^
Main.cpp:115:53: warning: array subscript has type 'char' [-Wchar-subscripts]
  115 |  for(int i=0; i<n; i++)ust(1, 0, N-1, i, i, cod[s[i]]);
      |                                                     ^
Main.cpp:123:28: warning: array subscript has type 'char' [-Wchar-subscripts]
  123 |   ust(1, 0, N-1, l, r, cod[c]);
      |                            ^
# Verdict Execution time Memory Grader output
1 Correct 394 ms 16748 KB Output is correct
2 Correct 424 ms 16844 KB Output is correct
3 Correct 481 ms 16820 KB Output is correct
4 Correct 409 ms 16728 KB Output is correct
5 Correct 399 ms 18304 KB Output is correct
6 Correct 476 ms 18228 KB Output is correct
7 Correct 437 ms 18364 KB Output is correct
8 Correct 427 ms 18344 KB Output is correct
9 Correct 436 ms 18364 KB Output is correct
10 Correct 406 ms 18336 KB Output is correct
11 Correct 490 ms 18288 KB Output is correct
12 Correct 398 ms 18360 KB Output is correct
13 Correct 421 ms 18364 KB Output is correct
14 Correct 438 ms 18292 KB Output is correct
15 Correct 419 ms 18360 KB Output is correct
16 Correct 423 ms 18372 KB Output is correct
17 Correct 450 ms 18316 KB Output is correct
18 Correct 430 ms 18276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 394 ms 16748 KB Output is correct
2 Correct 424 ms 16844 KB Output is correct
3 Correct 481 ms 16820 KB Output is correct
4 Correct 409 ms 16728 KB Output is correct
5 Correct 399 ms 18304 KB Output is correct
6 Correct 476 ms 18228 KB Output is correct
7 Correct 437 ms 18364 KB Output is correct
8 Correct 427 ms 18344 KB Output is correct
9 Correct 436 ms 18364 KB Output is correct
10 Correct 406 ms 18336 KB Output is correct
11 Correct 490 ms 18288 KB Output is correct
12 Correct 398 ms 18360 KB Output is correct
13 Correct 421 ms 18364 KB Output is correct
14 Correct 438 ms 18292 KB Output is correct
15 Correct 419 ms 18360 KB Output is correct
16 Correct 423 ms 18372 KB Output is correct
17 Correct 450 ms 18316 KB Output is correct
18 Correct 430 ms 18276 KB Output is correct
19 Correct 851 ms 35004 KB Output is correct
20 Correct 752 ms 34940 KB Output is correct
21 Correct 661 ms 33880 KB Output is correct
22 Correct 606 ms 32296 KB Output is correct
23 Correct 546 ms 19936 KB Output is correct
24 Correct 515 ms 19844 KB Output is correct
25 Correct 728 ms 34832 KB Output is correct
26 Correct 763 ms 34996 KB Output is correct
27 Correct 844 ms 34912 KB Output is correct
28 Correct 972 ms 34828 KB Output is correct
29 Correct 844 ms 34436 KB Output is correct
30 Correct 633 ms 19988 KB Output is correct
31 Correct 867 ms 34912 KB Output is correct
32 Correct 782 ms 33460 KB Output is correct
33 Correct 540 ms 19844 KB Output is correct
34 Correct 781 ms 34828 KB Output is correct
35 Correct 720 ms 30744 KB Output is correct
36 Correct 580 ms 19836 KB Output is correct
37 Correct 519 ms 20048 KB Output is correct
38 Correct 822 ms 34652 KB Output is correct
39 Correct 698 ms 34976 KB Output is correct
40 Correct 720 ms 29600 KB Output is correct
41 Correct 1010 ms 35108 KB Output is correct
42 Correct 584 ms 34332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 394 ms 16748 KB Output is correct
2 Correct 424 ms 16844 KB Output is correct
3 Correct 481 ms 16820 KB Output is correct
4 Correct 409 ms 16728 KB Output is correct
5 Correct 399 ms 18304 KB Output is correct
6 Correct 476 ms 18228 KB Output is correct
7 Correct 437 ms 18364 KB Output is correct
8 Correct 427 ms 18344 KB Output is correct
9 Correct 436 ms 18364 KB Output is correct
10 Correct 406 ms 18336 KB Output is correct
11 Correct 490 ms 18288 KB Output is correct
12 Correct 398 ms 18360 KB Output is correct
13 Correct 421 ms 18364 KB Output is correct
14 Correct 438 ms 18292 KB Output is correct
15 Correct 419 ms 18360 KB Output is correct
16 Correct 423 ms 18372 KB Output is correct
17 Correct 450 ms 18316 KB Output is correct
18 Correct 430 ms 18276 KB Output is correct
19 Correct 541 ms 18196 KB Output is correct
20 Correct 528 ms 18440 KB Output is correct
21 Correct 481 ms 18284 KB Output is correct
22 Correct 459 ms 18100 KB Output is correct
23 Correct 509 ms 18432 KB Output is correct
24 Correct 438 ms 18200 KB Output is correct
25 Correct 465 ms 18228 KB Output is correct
26 Correct 525 ms 18224 KB Output is correct
27 Correct 454 ms 18284 KB Output is correct
28 Correct 433 ms 18136 KB Output is correct
29 Correct 596 ms 18240 KB Output is correct
30 Correct 436 ms 18148 KB Output is correct
31 Correct 507 ms 18240 KB Output is correct
32 Correct 466 ms 18288 KB Output is correct
33 Correct 435 ms 18404 KB Output is correct
34 Correct 494 ms 18104 KB Output is correct
35 Correct 434 ms 18292 KB Output is correct
36 Correct 501 ms 18328 KB Output is correct
37 Correct 487 ms 18304 KB Output is correct
38 Correct 484 ms 18292 KB Output is correct
39 Correct 502 ms 18292 KB Output is correct
40 Correct 483 ms 18284 KB Output is correct
41 Correct 499 ms 18332 KB Output is correct
42 Correct 486 ms 18256 KB Output is correct
43 Correct 463 ms 18228 KB Output is correct
44 Correct 493 ms 18332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 394 ms 16748 KB Output is correct
2 Correct 424 ms 16844 KB Output is correct
3 Correct 481 ms 16820 KB Output is correct
4 Correct 409 ms 16728 KB Output is correct
5 Correct 399 ms 18304 KB Output is correct
6 Correct 476 ms 18228 KB Output is correct
7 Correct 437 ms 18364 KB Output is correct
8 Correct 427 ms 18344 KB Output is correct
9 Correct 436 ms 18364 KB Output is correct
10 Correct 406 ms 18336 KB Output is correct
11 Correct 490 ms 18288 KB Output is correct
12 Correct 398 ms 18360 KB Output is correct
13 Correct 421 ms 18364 KB Output is correct
14 Correct 438 ms 18292 KB Output is correct
15 Correct 419 ms 18360 KB Output is correct
16 Correct 423 ms 18372 KB Output is correct
17 Correct 450 ms 18316 KB Output is correct
18 Correct 430 ms 18276 KB Output is correct
19 Correct 851 ms 35004 KB Output is correct
20 Correct 752 ms 34940 KB Output is correct
21 Correct 661 ms 33880 KB Output is correct
22 Correct 606 ms 32296 KB Output is correct
23 Correct 546 ms 19936 KB Output is correct
24 Correct 515 ms 19844 KB Output is correct
25 Correct 728 ms 34832 KB Output is correct
26 Correct 763 ms 34996 KB Output is correct
27 Correct 844 ms 34912 KB Output is correct
28 Correct 972 ms 34828 KB Output is correct
29 Correct 844 ms 34436 KB Output is correct
30 Correct 633 ms 19988 KB Output is correct
31 Correct 867 ms 34912 KB Output is correct
32 Correct 782 ms 33460 KB Output is correct
33 Correct 540 ms 19844 KB Output is correct
34 Correct 781 ms 34828 KB Output is correct
35 Correct 720 ms 30744 KB Output is correct
36 Correct 580 ms 19836 KB Output is correct
37 Correct 519 ms 20048 KB Output is correct
38 Correct 822 ms 34652 KB Output is correct
39 Correct 698 ms 34976 KB Output is correct
40 Correct 720 ms 29600 KB Output is correct
41 Correct 1010 ms 35108 KB Output is correct
42 Correct 584 ms 34332 KB Output is correct
43 Correct 541 ms 18196 KB Output is correct
44 Correct 528 ms 18440 KB Output is correct
45 Correct 481 ms 18284 KB Output is correct
46 Correct 459 ms 18100 KB Output is correct
47 Correct 509 ms 18432 KB Output is correct
48 Correct 438 ms 18200 KB Output is correct
49 Correct 465 ms 18228 KB Output is correct
50 Correct 525 ms 18224 KB Output is correct
51 Correct 454 ms 18284 KB Output is correct
52 Correct 433 ms 18136 KB Output is correct
53 Correct 596 ms 18240 KB Output is correct
54 Correct 436 ms 18148 KB Output is correct
55 Correct 507 ms 18240 KB Output is correct
56 Correct 466 ms 18288 KB Output is correct
57 Correct 435 ms 18404 KB Output is correct
58 Correct 494 ms 18104 KB Output is correct
59 Correct 434 ms 18292 KB Output is correct
60 Correct 501 ms 18328 KB Output is correct
61 Correct 487 ms 18304 KB Output is correct
62 Correct 484 ms 18292 KB Output is correct
63 Correct 502 ms 18292 KB Output is correct
64 Correct 483 ms 18284 KB Output is correct
65 Correct 499 ms 18332 KB Output is correct
66 Correct 486 ms 18256 KB Output is correct
67 Correct 463 ms 18228 KB Output is correct
68 Correct 493 ms 18332 KB Output is correct
69 Correct 897 ms 32136 KB Output is correct
70 Correct 972 ms 34848 KB Output is correct
71 Correct 633 ms 19984 KB Output is correct
72 Correct 623 ms 19928 KB Output is correct
73 Correct 560 ms 19940 KB Output is correct
74 Correct 802 ms 32120 KB Output is correct
75 Correct 660 ms 19948 KB Output is correct
76 Correct 771 ms 34912 KB Output is correct
77 Correct 781 ms 32272 KB Output is correct
78 Correct 603 ms 19848 KB Output is correct
79 Correct 579 ms 19884 KB Output is correct
80 Correct 611 ms 30212 KB Output is correct
81 Correct 732 ms 19832 KB Output is correct
82 Correct 790 ms 35048 KB Output is correct
83 Correct 763 ms 33964 KB Output is correct
84 Correct 531 ms 19944 KB Output is correct
85 Correct 511 ms 20064 KB Output is correct
86 Correct 796 ms 31016 KB Output is correct
87 Correct 776 ms 34884 KB Output is correct
88 Correct 544 ms 19912 KB Output is correct
89 Correct 707 ms 32836 KB Output is correct
90 Correct 828 ms 34840 KB Output is correct
91 Correct 531 ms 19848 KB Output is correct
92 Correct 626 ms 30768 KB Output is correct
93 Correct 570 ms 19944 KB Output is correct
94 Correct 646 ms 19924 KB Output is correct
95 Correct 513 ms 19968 KB Output is correct
96 Correct 767 ms 34732 KB Output is correct
97 Correct 684 ms 35004 KB Output is correct
98 Correct 717 ms 29600 KB Output is correct
99 Correct 1008 ms 35148 KB Output is correct
100 Correct 601 ms 34308 KB Output is correct