QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141344#6515. Path Planningcy1999WA 29ms5784kbC++664b2023-08-17 10:58:052023-08-17 10:58:09

Judging History

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

  • [2023-08-17 10:58:09]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:5784kb
  • [2023-08-17 10:58:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define it set<pair<int,int> >::iterator
int t,n,m,dx[1000005],dy[1000005],ok;
set<pair<int,int> >q;
signed main(){
	cin>>t;
	while(t--){
		q.clear();
		cin>>n>>m;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				int x;
				scanf("%lld",&x);
				dx[x]=i,dy[x]=j;
			}
		}ok=1;
		for(int i=0;i<n*m;i++){
			q.insert(make_pair(dx[i],dy[i]));
			it w=q.find(make_pair(dx[i],dy[i])),k=w;
			k++;
			if(k!=q.end()){
				w++;
				if((*w).first>dx[i]&&(*w).second<dy[i]){
					printf("%lld\n",i-1);ok=0;
					break;
				}
			}
		}
		if(ok)printf("%lld\n",n*m);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 29ms
memory: 5720kb

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:

10
3
6
6
5
3
13
15
7
10
4
6
6
8
9
5
6
7
12
8
9
10
7
0
4
8
3
5
9
3
17
4
11
3
7
5
9
5
1
4
6
10
13
3
1
6
9
5
10
13
10
9
2
10
3
5
9
8
2
9
1
2
2
8
8
9
7
8
12
9
9
6
6
4
2
6
7
13
7
8
5
4
3
3
21
6
15
6
1
10
5
6
6
10
9
4
2
10
2
4
2
8
6
10
4
6
10
3
5
6
11
7
9
5
3
12
5
3
7
8
8
2
20
4
3
4
7
6
7
6
6
8
4
5
13
4
5...

result:

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