답안 #502079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502079 2022-01-05T08:58:22 Z beksultan04 Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 10320 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=0;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;
		if (s[1][i] == 'J')
			q[1][i] = 1;
		if (s[2][i] == 'J')
			q[2][i] = 1;
		if (s[0][i] == 'O')
			q[0][i] = 2;
		if (s[1][i] == 'O')
			q[1][i] = 2;
		if (s[2][i] == 'O')
			q[2][i] = 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;
		if (s[3][i] == 'O')
			w[i] = 2;
		for (j=0;j<9;++j){
			if (q[j][i] == w[i]){
				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-1;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 356 ms 2224 KB Output is correct
2 Correct 430 ms 2452 KB Output is correct
3 Correct 789 ms 2268 KB Output is correct
4 Correct 413 ms 2348 KB Output is correct
5 Correct 367 ms 2348 KB Output is correct
6 Correct 366 ms 2268 KB Output is correct
7 Correct 355 ms 2344 KB Output is correct
8 Correct 388 ms 2488 KB Output is correct
9 Correct 375 ms 2460 KB Output is correct
10 Correct 399 ms 2460 KB Output is correct
11 Correct 370 ms 2372 KB Output is correct
12 Correct 422 ms 2376 KB Output is correct
13 Correct 388 ms 2592 KB Output is correct
14 Correct 388 ms 2352 KB Output is correct
15 Correct 388 ms 2452 KB Output is correct
16 Correct 398 ms 2404 KB Output is correct
17 Correct 379 ms 2360 KB Output is correct
18 Correct 594 ms 2312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 356 ms 2224 KB Output is correct
2 Correct 430 ms 2452 KB Output is correct
3 Correct 789 ms 2268 KB Output is correct
4 Correct 413 ms 2348 KB Output is correct
5 Correct 367 ms 2348 KB Output is correct
6 Correct 366 ms 2268 KB Output is correct
7 Correct 355 ms 2344 KB Output is correct
8 Correct 388 ms 2488 KB Output is correct
9 Correct 375 ms 2460 KB Output is correct
10 Correct 399 ms 2460 KB Output is correct
11 Correct 370 ms 2372 KB Output is correct
12 Correct 422 ms 2376 KB Output is correct
13 Correct 388 ms 2592 KB Output is correct
14 Correct 388 ms 2352 KB Output is correct
15 Correct 388 ms 2452 KB Output is correct
16 Correct 398 ms 2404 KB Output is correct
17 Correct 379 ms 2360 KB Output is correct
18 Correct 594 ms 2312 KB Output is correct
19 Execution timed out 7066 ms 10320 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 356 ms 2224 KB Output is correct
2 Correct 430 ms 2452 KB Output is correct
3 Correct 789 ms 2268 KB Output is correct
4 Correct 413 ms 2348 KB Output is correct
5 Correct 367 ms 2348 KB Output is correct
6 Correct 366 ms 2268 KB Output is correct
7 Correct 355 ms 2344 KB Output is correct
8 Correct 388 ms 2488 KB Output is correct
9 Correct 375 ms 2460 KB Output is correct
10 Correct 399 ms 2460 KB Output is correct
11 Correct 370 ms 2372 KB Output is correct
12 Correct 422 ms 2376 KB Output is correct
13 Correct 388 ms 2592 KB Output is correct
14 Correct 388 ms 2352 KB Output is correct
15 Correct 388 ms 2452 KB Output is correct
16 Correct 398 ms 2404 KB Output is correct
17 Correct 379 ms 2360 KB Output is correct
18 Correct 594 ms 2312 KB Output is correct
19 Correct 487 ms 2332 KB Output is correct
20 Correct 1165 ms 2412 KB Output is correct
21 Correct 420 ms 2528 KB Output is correct
22 Correct 370 ms 2268 KB Output is correct
23 Correct 418 ms 2564 KB Output is correct
24 Correct 374 ms 2268 KB Output is correct
25 Correct 443 ms 2372 KB Output is correct
26 Correct 369 ms 2292 KB Output is correct
27 Correct 436 ms 2404 KB Output is correct
28 Correct 393 ms 2284 KB Output is correct
29 Correct 397 ms 2408 KB Output is correct
30 Correct 407 ms 2256 KB Output is correct
31 Correct 472 ms 2620 KB Output is correct
32 Correct 449 ms 2344 KB Output is correct
33 Correct 436 ms 2460 KB Output is correct
34 Correct 387 ms 2244 KB Output is correct
35 Correct 459 ms 2400 KB Output is correct
36 Correct 455 ms 2452 KB Output is correct
37 Correct 448 ms 2372 KB Output is correct
38 Correct 441 ms 2452 KB Output is correct
39 Correct 461 ms 2456 KB Output is correct
40 Correct 426 ms 2368 KB Output is correct
41 Correct 455 ms 2412 KB Output is correct
42 Correct 437 ms 2372 KB Output is correct
43 Correct 420 ms 2516 KB Output is correct
44 Correct 427 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 356 ms 2224 KB Output is correct
2 Correct 430 ms 2452 KB Output is correct
3 Correct 789 ms 2268 KB Output is correct
4 Correct 413 ms 2348 KB Output is correct
5 Correct 367 ms 2348 KB Output is correct
6 Correct 366 ms 2268 KB Output is correct
7 Correct 355 ms 2344 KB Output is correct
8 Correct 388 ms 2488 KB Output is correct
9 Correct 375 ms 2460 KB Output is correct
10 Correct 399 ms 2460 KB Output is correct
11 Correct 370 ms 2372 KB Output is correct
12 Correct 422 ms 2376 KB Output is correct
13 Correct 388 ms 2592 KB Output is correct
14 Correct 388 ms 2352 KB Output is correct
15 Correct 388 ms 2452 KB Output is correct
16 Correct 398 ms 2404 KB Output is correct
17 Correct 379 ms 2360 KB Output is correct
18 Correct 594 ms 2312 KB Output is correct
19 Execution timed out 7066 ms 10320 KB Time limit exceeded
20 Halted 0 ms 0 KB -