UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212812#3828. Braoxuanrui102100ms1216kbC++806b2024-10-20 11:45:272024-10-20 14:39:10

answer

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int ma=-1;
bool ss[1001][1001];
int a[1001][1001],n,m;
int dfs(int x,int y,int l){
	cout<<a[x][y];
	ss[x][y]=1;
	if(ss[x-1][y] && ss[x+1][y] && ss[x][y-1] && ss[x][y+1]&& x-1>=0 && x+1<n && y-1>=0 && y+1<m){
		cout<<endl;
		return l;
	}
	int m=l;
	for(int i=-1;i<=1;i+=2){
		for(int j=-1;j<=1;j+=2){
			if(a[x-i][y-j]>a[x][y] && x-i>=0 && x-i<n && y-j>=0 && y-j<m){
				m=max(m,dfs(x-i,y-j,l+1));
			}
		}
	}
	ss[x][y]=0;
	return m;
}
int main(){
	int k;
	cin>>k;
	while(k--){
		cin>>n>>m;
		 for(int i=0;i<n;i++){
		 	for(int j=0;j<m;j++){
		 		cin>>a[i][j];
			 }
		 }
		 for(int i=0;i<n;i++){
		 	for(int j=0;j<m;j++){
		 		ma=max(dfs(i,j,1),ma);
			 }
		 }
		 cout<<ma<<endl;
	}
	
	return 0;
}

Details

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

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1216kb

input:

10
3 3
0 1 2
3 4 5
6 7 8
3 3
0 1 2
3 4 5
6 8 7
3 3
0 1 2
3 4 5
7 6 8
3 3
0 1 2
3 4 5
7 8 6
3 3
0 1 2...

output:

0137234656783
0138234656873
0136234757683
0138234757863
0136234858673
0137234858763
0137234565783
01...

result:

wrong output format Expected integer, but "0137234656783" found

Subtask #2:

score: 0
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

input:

10
22 45
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33...

output:

0189911771832652753533674414595295516176437057357938278819199699719179719738839179719739159739758258...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded

input:

10
2 100000
143604 106821 145034 44402 118718 156663 77133 28800 81890 12336 191537 118894 103331 75...

output:

1436041068211450344440211871815666377133288008189012336191537118894103331757509397011665912780215255...

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #6:

score: 0
Time Limit Exceeded

input:

10
1 200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32...

output:

0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354...

result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

input:

10
145 1379
140324 86968 96426 123781 39754 103720 60835 118904 114639 53717 27146 110309 39232 5608...

output:

1403248696815840096426123781397541037206083511890411463953717271461103093923256083169538176264137818...

result: