답안 #502110

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502110 2022-01-05T10:02:18 Z beksultan04 Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 9828 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//#define int long long
#define pii pair<int,int>
#define ret return
#define fr first
#define sc second
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define nosol puts("-1");
#define pb push_back
#define endi puts("");
#define ordered_set tree <int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 2e5+12,INF = 1e9+7;
int q[10][N],w[N],n,ans[10];
string s[5];

void fun(int a,int b,int c){
	for (int i=1;i<=n;++i)
		q[c][i] = ((3-(q[a][i]+q[b][i])+3)%3);
}
void is(){
	for (int i=0;i<9;++i){
		if (ans[i] == n){
			cout <<"Yes\n";
			ret ;
		}
	}
	cout <<"No\n";
}

int main(){
	int i,m,j;
	cin>>n;
	cin>>s[0]>>s[1]>>s[2];
	
	for (i=0;i<n;++i){
		if (s[0][i] == 'J')
			q[0][i+1] = 1;
		if (s[1][i] == 'J')
			q[1][i+1] = 1;
		if (s[2][i] == 'J')
			q[2][i+1] = 1;
		if (s[0][i] == 'O')
			q[0][i+1] = 2;
		if (s[1][i] == 'O')
			q[1][i+1] = 2;
		if (s[2][i] == 'O')
			q[2][i+1] = 2;
	}
	fun(0,1,3);
	fun(0,2,4);
	fun(1,2,5);
	fun(3,2,6);
	fun(4,1,7);
	fun(5,0,8);
	cin>>m;
	cin>>s[3];
	
	for (i=0;i<n;++i){
		if (s[3][i] == 'J')
			w[i+1] = 1;
		if (s[3][i] == 'O')
			w[i+1] = 2;
		for (j=0;j<9;++j){
			if (q[j][i+1] == w[i+1]){
				ans[j]++;
			}
		}
	}
	is();
	while (m--){
		int l,r,z=0;
		char ch;
		cin>>l>>r>>ch;
		if (ch == 'J')z = 1;
		if (ch == 'O')z = 2;
		for (i=l;i<=r;++i){
			
			for (j=0;j<9;++j){
				if (q[j][i] == w[i]){
					ans[j]--;
				}
			}
			w[i] = z;
			for (j=0;j<9;++j){
				if (q[j][i] == w[i]){
					ans[j]++;
				}
			}
		}
		is();
	}
	
}








# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 1608 KB Output is correct
2 Correct 410 ms 1748 KB Output is correct
3 Correct 714 ms 1616 KB Output is correct
4 Correct 383 ms 1624 KB Output is correct
5 Correct 356 ms 1604 KB Output is correct
6 Correct 354 ms 1860 KB Output is correct
7 Correct 359 ms 1640 KB Output is correct
8 Correct 381 ms 1688 KB Output is correct
9 Correct 367 ms 1764 KB Output is correct
10 Correct 384 ms 1604 KB Output is correct
11 Correct 373 ms 1764 KB Output is correct
12 Correct 383 ms 1688 KB Output is correct
13 Correct 375 ms 1604 KB Output is correct
14 Correct 389 ms 1624 KB Output is correct
15 Correct 369 ms 1616 KB Output is correct
16 Correct 382 ms 1732 KB Output is correct
17 Correct 384 ms 1672 KB Output is correct
18 Correct 581 ms 1724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 1608 KB Output is correct
2 Correct 410 ms 1748 KB Output is correct
3 Correct 714 ms 1616 KB Output is correct
4 Correct 383 ms 1624 KB Output is correct
5 Correct 356 ms 1604 KB Output is correct
6 Correct 354 ms 1860 KB Output is correct
7 Correct 359 ms 1640 KB Output is correct
8 Correct 381 ms 1688 KB Output is correct
9 Correct 367 ms 1764 KB Output is correct
10 Correct 384 ms 1604 KB Output is correct
11 Correct 373 ms 1764 KB Output is correct
12 Correct 383 ms 1688 KB Output is correct
13 Correct 375 ms 1604 KB Output is correct
14 Correct 389 ms 1624 KB Output is correct
15 Correct 369 ms 1616 KB Output is correct
16 Correct 382 ms 1732 KB Output is correct
17 Correct 384 ms 1672 KB Output is correct
18 Correct 581 ms 1724 KB Output is correct
19 Execution timed out 7062 ms 9828 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 1608 KB Output is correct
2 Correct 410 ms 1748 KB Output is correct
3 Correct 714 ms 1616 KB Output is correct
4 Correct 383 ms 1624 KB Output is correct
5 Correct 356 ms 1604 KB Output is correct
6 Correct 354 ms 1860 KB Output is correct
7 Correct 359 ms 1640 KB Output is correct
8 Correct 381 ms 1688 KB Output is correct
9 Correct 367 ms 1764 KB Output is correct
10 Correct 384 ms 1604 KB Output is correct
11 Correct 373 ms 1764 KB Output is correct
12 Correct 383 ms 1688 KB Output is correct
13 Correct 375 ms 1604 KB Output is correct
14 Correct 389 ms 1624 KB Output is correct
15 Correct 369 ms 1616 KB Output is correct
16 Correct 382 ms 1732 KB Output is correct
17 Correct 384 ms 1672 KB Output is correct
18 Correct 581 ms 1724 KB Output is correct
19 Correct 442 ms 1580 KB Output is correct
20 Correct 1049 ms 1648 KB Output is correct
21 Correct 414 ms 1656 KB Output is correct
22 Correct 342 ms 1616 KB Output is correct
23 Correct 407 ms 1660 KB Output is correct
24 Correct 381 ms 1572 KB Output is correct
25 Correct 421 ms 1684 KB Output is correct
26 Correct 364 ms 1604 KB Output is correct
27 Correct 404 ms 1692 KB Output is correct
28 Correct 375 ms 1616 KB Output is correct
29 Correct 399 ms 1640 KB Output is correct
30 Correct 352 ms 1624 KB Output is correct
31 Correct 456 ms 1628 KB Output is correct
32 Correct 447 ms 1788 KB Output is correct
33 Correct 421 ms 1612 KB Output is correct
34 Correct 381 ms 1604 KB Output is correct
35 Correct 439 ms 1680 KB Output is correct
36 Correct 446 ms 1604 KB Output is correct
37 Correct 446 ms 1604 KB Output is correct
38 Correct 435 ms 1644 KB Output is correct
39 Correct 463 ms 1648 KB Output is correct
40 Correct 431 ms 1620 KB Output is correct
41 Correct 465 ms 1876 KB Output is correct
42 Correct 431 ms 1664 KB Output is correct
43 Correct 401 ms 1612 KB Output is correct
44 Correct 434 ms 1760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 1608 KB Output is correct
2 Correct 410 ms 1748 KB Output is correct
3 Correct 714 ms 1616 KB Output is correct
4 Correct 383 ms 1624 KB Output is correct
5 Correct 356 ms 1604 KB Output is correct
6 Correct 354 ms 1860 KB Output is correct
7 Correct 359 ms 1640 KB Output is correct
8 Correct 381 ms 1688 KB Output is correct
9 Correct 367 ms 1764 KB Output is correct
10 Correct 384 ms 1604 KB Output is correct
11 Correct 373 ms 1764 KB Output is correct
12 Correct 383 ms 1688 KB Output is correct
13 Correct 375 ms 1604 KB Output is correct
14 Correct 389 ms 1624 KB Output is correct
15 Correct 369 ms 1616 KB Output is correct
16 Correct 382 ms 1732 KB Output is correct
17 Correct 384 ms 1672 KB Output is correct
18 Correct 581 ms 1724 KB Output is correct
19 Execution timed out 7062 ms 9828 KB Time limit exceeded
20 Halted 0 ms 0 KB -