QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190613 | #2832. Graph Theory | qzez# | WA | 14ms | 3892kb | C++14 | 1.2kb | 2023-09-29 07:41:10 | 2023-09-29 07:41:10 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e5+5,M=N*100+5,K=600+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
int n,m,A[N],B[N],f[N];
int CK(int mid){
fill(f+1,f+n+1,0);int i;
for(int i=1;i<=n;i++) {
if(B[i]-A[i]>mid) f[1]++,f[A[i]]--,f[B[i]]++;
if(n-(B[i]-A[i])>mid) f[A[i]]++,f[B[i]]--;
}
for(i=1;i<=n;i++) f[i]+=f[i-1];
for(i=1;i<=n;i++) if(!f[i]) return 1;
return 0;
}
void Solve(){
int i,j;if(scanf("%d%d",&n,&m)==-1) exit(0);
for(i=1;i<=m;i++) scanf("%d%d",&A[i],&B[i]),A[i]>B[i]&&(swap(A[i],B[i]),0);
int l=-1,r=n+1,mid;while(l+1<r) mid=l+r>>1,(CK(mid)?r:l)=mid;
printf("%d\n",r);
}
int main(){
int t=1;
// scanf("%d",&t);
while(1) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
3 2 1 2 2 3 3 2 1 1 2 2 3 3 1 2 2 3 3 1
output:
1 0 2
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
2 1 1 2
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Wrong Answer
time: 14ms
memory: 3892kb
input:
17 17 6 10 1 9 14 6 12 13 5 4 15 17 14 15 6 5 10 6 10 11 2 9 9 6 17 15 9 15 4 8 1 4 13 15 13 19 11 10 12 10 10 5 2 8 12 11 8 3 1 7 10 9 8 5 1 5 9 4 8 7 12 10 6 8 13 1 5 8 11 5 10 8 7 7 16 14 9 5 8 1 4 16 10 8 16 15 15 1 13 5 9 3 4 4 9 7 7 2 5 4 5 11 9 14 5 13 1 5 4 5 4 1 4 4 1 1 5 3 3 5 4 1 3 2 5 1 ...
output:
8 6 11 2 1 1 7 6 2 8 2 9 11 10 9 14 3 8 11 9 11 10 4 10 6 8 4 2 2 6 6 5 8 4 1 10 4 1 12 6 9 2 6 5 1 2 0 3 6 8 8 6 3 4 7 6 3 11 1 5 3 2 0 5 8 4 8 5 8 9 10 10 3 2 5 9 4 8 6 6 6 1 4 2 4 1 9 7 3 9 7 7 8 5 7 6 1 4 8 5 7 4 5 3 3 7 7 8 9 2 9 3 3 7 10 8 1 2 2 6 6 7 8 8 2 5 1 3 7 3 1 9 13 5 11 5 2 3 1 6 6 4 ...
result:
wrong answer 3rd lines differ - expected: '8', found: '11'