QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#141428 | #6515. Path Planning | cy1999 | WA | 1ms | 3400kb | C++ | 811b | 2023-08-17 12:01:27 | 2023-08-17 12:01:30 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'