QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#141385#6515. Path Planningcy1999WA 36ms3612kbC++20643b2023-08-17 11:19:592023-08-17 11:20:02

Judging History

你现在查看的是最新测评结果

  • [2023-08-17 11:20:02]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:3612kb
  • [2023-08-17 11:19:59]
  • 提交

answer

#include<iostream>
#define int long long
using namespace std;
const int N=1e6+10;
int t,n,m,c,a[N];
int px(int r){
	return r/m;
}
int py(int r){
	return r%m;
}
int pz(int x,int y){
	return x*m+y;
}
bool check(int r){
	int rx=px(a[r]);
	int ry=py(a[r]);
	int nx=px(a[r+1]);
	int ny=py(a[r+1]);
	if(rx<=nx&&ry<=ny)return true;
	if(rx>=nx&&ry>=ny)return true;
	return false;
}
signed main(){
	cin>>t;
	while(t--){
		cin>>n>>m;
		for(int i=0;i<=n-1;i++){
			for(int j=0;j<=m-1;j++){
				cin>>c;
				a[c]=pz(i,j);
			}
		}
		int ans=0;
		while(ans<=n*m-2&&check(ans))ans++;
		cout<<ans+1<<endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3400kb

input:

2
2 3
1 2 4
3 0 5
1 5
1 3 0 4 2

output:

3
5

result:

ok 2 number(s): "3 5"

Test #2:

score: -100
Wrong Answer
time: 36ms
memory: 3612kb

input:

10000
2 9
4 0 3 5 2 7 16 11 12
9 13 14 17 10 8 15 1 6
4 8
19 23 22 13 29 4 17 26
30 6 25 3 15 24 18 14
12 8 7 9 27 5 0 10
11 16 31 20 2 28 1 21
1 6
3 2 0 1 4 5
2 3
4 2 0
3 5 1
5 1
4
0
3
2
1
1 3
1 0 2
8 10
9 50 8 0 41 57 60 30 23 65
64 21 36 12 10 5 58 19 38 67
71 52 45 17 77 4 59 51 22 25
56 49 79 2...

output:

11
4
6
3
5
3
15
16
5
9
7
8
7
12
7
4
6
7
17
9
11
9
8
1
6
8
4
2
12
5
18
5
13
3
7
7
10
2
1
6
6
10
14
5
2
7
2
5
11
17
8
10
2
10
3
7
9
9
5
11
2
3
3
9
8
4
8
12
7
8
10
6
7
8
4
8
7
13
3
5
7
5
5
3
10
5
14
7
2
11
8
7
7
10
9
15
4
11
2
8
3
8
11
10
6
4
10
4
6
5
13
8
10
11
4
5
4
4
8
4
8
4
16
6
5
5
12
6
8
5
10
10
...

result:

wrong answer 1st numbers differ - expected: '9', found: '11'