QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141311#6515. Path Planningcy1999WA 24ms3668kbC++20767b2023-08-17 10:40:062023-08-17 10:40:08

Judging History

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

  • [2023-08-17 10:40:08]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3668kb
  • [2023-08-17 10:40:06]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

struct node{
	int id,x,y;
	
	friend bool operator<(const node &a,const node &b){
		return a.y<b.y;
	}
};

vector<node> p;
int n,m;

int chk(int mid){
	int lst=-1;
	for(int i=0; i<p.size(); i++){
		if(p[i].id>mid) continue;
		if(p[i].x<lst) return 0;
		lst=p[i].x;
	}
	return 1;
}

void solve(){
	p.clear();
	cin>>n>>m;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			int t;
			scanf("%d",&t);
			p.emplace_back((node){t,i,j});
		}
	}
	
	sort(p.begin(),p.end());
	
	int l=0, r=n*m-1;
	while(l<r){
		int mid=(l+r+1)>>1;
		if(chk(mid)) l=mid;
		else r=mid-1;
	}
	
	printf("%d\n",l+1);
	
	
}

int main(){
	
	int T;
	cin>>T;
	while(T--) solve();
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 24ms
memory: 3604kb

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:

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

result:

wrong answer 2nd numbers differ - expected: '2', found: '1'