QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#141428#6515. Path Planningcy1999WA 1ms3400kbC++811b2023-08-17 12:01:272023-08-17 12:01:30

Judging History

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

  • [2023-08-17 12:01:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3400kb
  • [2023-08-17 12:01:27]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast","inline")
#include<iostream>
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 o,int f){
	int ox=px(a[o]);
	int oy=py(a[o]);
	int fx=px(a[f]);
	int fy=py(a[f]);
	if(ox<fx&&oy>fy)return false;
	if(ox>fx&&oy<fy)return false;
	return true;
}
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 k=0;
		for(;k<=n*m-1;k++){
			int nx=px(a[k]);
			int i=0;
			for(;i<=k-1;i+=i%2+1)
				if(!check(k,i))
					break;
			if(i!=k)
				break;
		}
		cout<<k<<endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3400kb

input:

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

output:

2
2

result:

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