QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346995#2832. Graph TheoryxunxxxxWA 0ms3516kbC++20728b2024-03-09 09:36:072024-03-09 09:36:07

Judging History

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

  • [2024-03-09 09:36:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3516kb
  • [2024-03-09 09:36:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int l,r,mid,n,m,a[200010],b[200010],ans;
int ck(int x)
{
	int cnt=0;
	vector<int>d(n+1,0);
	for(int i=1;i<=m;i++)
	{
		if(min(b[i]-a[i],n-(b[i]-a[i]))>x) return 0;
		if(max(b[i]-a[i],n-(b[i]-a[i]))<=x) continue;
		cnt++;
		if(b[i]-a[i]>=n-(b[i]-a[i])) d[a[i]]++,d[b[i]]--;
		else d[1]++,d[a[i]]--,d[b[i]]++;  
	}
	for(int i=1;i<=n;i++)
	{
		d[i]+=d[i-1];
		if(d[i]==cnt) return 1;
	}
	return 0;
}
int main()
{
	while(cin>>n>>m)
	{
		cin>>n>>m;
		for(int i=1;i<=m;i++) 
		{
			cin>>a[i]>>b[i];
			if(a[i]>b[i]) swap(a[i],b[i]);
		}
		l=0,r=n;
		while(l<=r)
		{
			mid=l+r>>1;
			if(ck(mid)) r=mid-1;
			else l=mid+1;
		}
		cout<<l<<"\n";
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3516kb

input:

3 2
1 2
2 3
3 2
1 1
2 2
3 3
1 2
2 3
3 1

output:

1
1
0

result:

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