UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#210634#3784. 三消ranqizhang10043ms1492kbC++11981b2024-08-07 08:48:192024-08-07 12:01:25

answer

#include<bits/stdc++.h>
using namespace std; 
int a[251][251];
char a1[251][251];
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>a1[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				a[i][j]=a1[i][j]-'0';
			}
		}
		int flag=0;
		for(int i=0;i<n;i++){
			for(int j=1;j<n-1;j++){
//				cout<<i<<' '<<j<<endl<<a[i][j-1]<<' '<<a[i][j]<<' '<<a[i][j+1]<<"\n";
				if(a[i][j]==a[i][j-1]&&a[i][j]==a[i][j+1]){
					cout<<"YES"<<endl;
					flag=1;
					break;
				}
			}
			if(flag==1){
				break;
			}
		}
		if(flag==1){
			continue;
		}
//		if(flag==0){
		for(int i=1;i<n-1;i++){
			for(int j=0;j<n;j++){
//				cout<<i<<' '<<j<<endl<<a[i-1][j]<<' '<<a[i][j]<<' '<<a[i+1][j]<<"\n";
				if(a[i][j]==a[i-1][j]&&a[i][j]==a[i+1][j]){
					cout<<"YES"<<endl;
					flag=1;
					break;
				}
			}
			if(flag==1){
				break;
			}
		}
		if(flag==0){
			cout<<"NO\n";
		}
	}
	return 0;
} 

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1200kb

input:

10
1
4
3
251
284
777
2
66
76
3
733
425
829
3
576
134
894
2
91
82
2
61
48
2
31
46
3
613
116
213
2
32
27

output:

NO
YES
NO
NO
NO
NO
NO
NO
YES
NO

result:

ok 10 tokens

Test #2:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

10
1
7
2
52
82
2
16
38
3
274
144
984
3
344
474
853
3
489
555
732
3
639
744
387
2
73
41
2
97
71
3
393...

output:

NO
NO
NO
YES
NO
YES
NO
NO
NO
NO

result:

ok 10 tokens

Test #3:

score: 10
Accepted
time: 3ms
memory: 1492kb

input:

7
95
17651417424181721978237619789531423646346534865234575234878214678515172545865784363531351235274...

output:

NO
NO
YES
NO
NO
YES
NO

result:

ok 7 tokens

Test #4:

score: 10
Accepted
time: 6ms
memory: 1492kb

input:

7
91
8585518348588177575942837191341957373282257228992397166972685136746933589624541746784251894
661...

output:

YES
NO
NO
NO
YES
YES
YES

result:

ok 7 tokens

Test #5:

score: 10
Accepted
time: 5ms
memory: 1492kb

input:

7
100
7352952852347574521479613936473573915192765937851832586243157698751834121983793545751319821717...

output:

NO
NO
YES
YES
YES
NO
NO

result:

ok 7 tokens

Test #6:

score: 10
Accepted
time: 6ms
memory: 1432kb

input:

10
3
333
295
769
3
763
145
777
3
493
338
194
3
711
824
478
3
771
457
956
197
45135747252243141866653...

output:

YES
YES
NO
NO
NO
YES
NO
NO
NO
NO

result:

ok 10 tokens

Test #7:

score: 10
Accepted
time: 7ms
memory: 1432kb

input:

10
3
694
274
935
3
416
326
297
3
384
955
767
3
366
451
719
3
593
516
521
197
67753333392919715815498...

output:

NO
NO
NO
NO
YES
YES
NO
YES
NO
NO

result:

ok 10 tokens

Test #8:

score: 10
Accepted
time: 3ms
memory: 1436kb

input:

10
3
525
195
529
3
752
253
397
3
514
111
715
3
779
862
483
3
319
592
834
197
18319896569626859837167...

output:

NO
NO
YES
NO
NO
NO
YES
YES
NO
NO

result:

ok 10 tokens

Test #9:

score: 10
Accepted
time: 7ms
memory: 1440kb

input:

5
199
8959198476949295838713942564613946846382364396439165349598146157218949589751457824678747854983...

output:

YES
YES
NO
YES
YES

result:

ok 5 tokens

Test #10:

score: 10
Accepted
time: 6ms
memory: 1436kb

input:

5
199
9185865397256416195372578751367292327679754643725345896878429158493846231964529172495245893757...

output:

NO
NO
YES
NO
YES

result:

ok 5 tokens

Extra Test:

score: 0
Extra Test Passed