QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21751 | #2832. Graph Theory | Jackyqwq# | WA | 123ms | 15524kb | C++14 | 946b | 2022-03-08 14:56:30 | 2022-05-08 04:01:23 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define db double
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
const int maxn=5e5;
int n,m;
vector<int> G[maxn+5];
int MX(multiset<int> &S) {
multiset<int>::iterator it=S.end();
it--;
return *it;
}
int main() {
while (cin>>n>>m){
multiset<int> S;
S.clear();
for (int i=1;i<=2*n;i++) G[i].clear();
int flag=0;
for (int i=1;i<=m;i++) {
int u,v;
scanf("%d %d",&u,&v);
if (u>v) swap(u,v);
if (u==v) {
flag=1;
}
G[u].push_back(v);
S.insert(v-u);
}
if (flag==1) {
cout<<0<<'\n';
continue ;
}
int ans=1e9;
for (int i=1;i<=n;i++) {
ans=min(ans,MX(S));
for (auto v:G[i]) {
S.erase(S.find(v-i));
S.insert(i+n-v);
G[v].push_back(i+n);
}
}
cout<<ans<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 15524kb
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: 15464kb
input:
2 1 1 2
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Wrong Answer
time: 123ms
memory: 15472kb
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 0 0 0 1 0 0 0 2 0 0 9 0 0 8 0 0 0 7 7 9 0 4 8 0 8 2 0 2 0 0 0 5 0 0 0 0 1 0 0 9 0 0 4 0 0 0 3 6 8 0 0 0 0 0 6 0 8 0 0 0 0 0 5 8 0 0 5 0 7 0 0 3 0 0 7 0 5 0 6 5 0 4 0 0 0 0 7 0 9 4 6 0 5 0 0 0 0 0 5 6 4 0 0 0 0 0 6 9 0 0 0 3 7 10 7 0 0 0 0 6 0 0 7 0 0 0 0 7 2 0 0 9 0 0 0 0 0 1 0 0 3 0 0 0 8 0 0 3 0...
result:
wrong answer 2nd lines differ - expected: '6', found: '0'