QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141360#6531. Base Station Constructioncy1999WA 1ms5512kbC++11931b2023-08-17 11:09:082023-08-17 11:09:10

Judging History

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

  • [2023-08-17 11:09:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5512kb
  • [2023-08-17 11:09:08]
  • 提交

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'