QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368214#2832. Graph Theoryhshshs#WA 0ms3668kbC++14827b2024-03-26 22:04:332024-03-26 22:04:33

Judging History

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

  • [2024-03-26 22:04:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2024-03-26 22:04:33]
  • 提交

answer

#include<bits/stdc++.h>
#define maxn 200010
using namespace std;
int n,m,a[maxn],b[maxn],f[maxn];
int solve(int z){
	memset(f,0,sizeof(f));
	for(int i=1;i<=m;i++){
		if(b[i]-a[i]>z&&n-(b[i]-a[i])>z)return 0;
		else if(b[i]-a[i]<=z&&n-(b[i]-a[i])>z){
			f[a[i]]++,f[b[i]]--;
		}
		else if(b[i]-a[i]>z&&n-(b[i]-a[i])<=z){
			f[1]++,f[a[i]]--;
			f[b[i]]++,f[n+1]--;
		}
	}
	for(int i=1;i<=n;i++){
		f[i]+=f[i-1];
		if(f[i]==0)return 1; 
	}
	return 0;
}
int main() {
	freopen("F.in", "r", stdin); 
    while(~scanf("%d%d",&n,&m)){
	    for(int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
	    for(int i=1;i<=m;i++)if(a[i]>b[i])swap(a[i],b[i]);
		int l=0,r=n,mid,ans;
		while(l<=r){
			int mid=(l+r)>>1;
			if(solve(mid))ans=mid,r=mid-1;
			else l=mid+1;
		}	
		printf("%d\n",ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:


result:

wrong answer 1st lines differ - expected: '1', found: ''