QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#141360 | #6531. Base Station Construction | cy1999 | WA | 1ms | 5512kb | C++11 | 931b | 2023-08-17 11:09:08 | 2023-08-17 11:09:10 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
int x[N],y[N];
int t;
int n,m;
vector<pair<int,int> > w;
signed main()
{
cin>>t;
while(t--)
{
int p=-1;
w.clear();
cin>>n>>m;
int u1,u2;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int a;
cin>>a;
x[a]=i;
y[a]=j;
if(i==1&&j==1)
{
u1=a;
}
if(i==n&&j==m)
{
u2=a;
}
}
}
w.push_back(make_pair(u1,u2));
while(1)
{
int f=0;
p++;
int lw=w.size();
for(int i=0;i<lw;i++)
{
int a=w[i].first;
int b=w[i].second;
if(x[p]>=x[a]&&x[p]<=x[b]&&y[p]>=y[a]&&y[p]<=y[b])
{
f=1;
if(p==a||p==b)
{
break;
}
w[i].second=p;
w.push_back(make_pair(p,b));
break;
}
}
if(f==0)
{
break;
}
}
cout<<p<<endl;
//assert(p>0);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5512kb
input:
2 5 3 2 4 1 100 3 1 3 2 4 5 5 5 7 3 4 2 2 3 1 4 2 3 4 5
output:
0 0
result:
wrong answer 1st numbers differ - expected: '102', found: '0'