ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212766 | #3828. B | Rainxcy | 0 | 1ms | 1152kb | C++ | 1.6kb | 2024-10-20 10:44:28 | 2024-10-20 14:37:41 |
answer
#include <bits/stdc++.h>
using namespace std;
int t,n,m,a[1005][1005],ans[1005],Mcd=0,lj[1005],fx[]={1,0,-1,0,1};
bool vis[1005][1005];
int read();
void write(int x);
void dfs(int deep,int x,int y);
int main()
{
t=read();
for(int i=1;i<=t;i++){
n=read();
m=read();
Mcd=0;
lj[1]=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
a[i][j]=read();
}
}
dfs(1,1,1);
write(Mcd);
putchar('\n');
for(int i=1;i<=Mcd;i++){
write(ans[i]);
putchar(' ');
}
putchar('\n');
}
return 0;
}
int read(){
int x,y=1;char c;
while((c=getchar())>'9'||c<'0') if(c=='-') y=-1;
x=(c^48);
while((c=getchar())>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48);
return x*y;
}
void write(int x){
if(x<0) x=-x,putchar('-');
if(x>9) write(x/10);
putchar(x%10+48);
}
void dfs(int deep,int x,int y){
bool f=0;
for(int i=0;i<4;i++){
int nx=x+fx[i],ny=y+fx[i+1];
if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&a[nx][ny]>lj[deep]){
f=1;
lj[deep+1]=a[nx][ny];
dfs(deep+1,nx,ny);
}
}
if(f==0){
if(deep>Mcd){
Mcd=deep;
memcpy(ans,lj,sizeof(lj));
}
else if(deep==Mcd){
for(int i=1;i<=deep;i++){
if(lj[i]<ans[i]){
memcpy(ans,lj,sizeof(ans));
break;
}
}
}
}
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 20
Accepted
time: 0ms
memory: 1152kb
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:
5 0 1 2 5 8 6 0 1 2 5 7 8 5 0 1 2 5 8 6 0 1 2 5 6 8 5 0 1 2 5 7 7 0 1 2 5 6 7 8 5 0 1 2 6 8 6...
result:
ok 64 numbers
Test #2:
score: -20
Wrong Answer
time: 1ms
memory: 1148kb
input:
10 1 10 1 5 0 8 2 9 6 3 4 7 1 10 2 5 8 0 9 7 3 1 6 4 3 3 0 1 2 5 4 3 6 7 8 1 10 3 4 7 2 5 6 9 0 1 8 ...
output:
2 0 5 3 0 5 8 9 0 1 2 3 4 5 6 7 8 3 0 4 7 3 0 2 5 5 0 4 5 6 7 2 0 8 10 0 1 2 3 4 5 6 7 8 9 3...
result:
wrong answer 1st numbers differ - expected: '3', found: '2'
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:
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:
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:
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 33 3...
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...