結果
問題 | No.416 旅行会社 |
ユーザー | autumn-eel |
提出日時 | 2017-12-15 21:23:07 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,107 bytes |
コンパイル時間 | 1,926 ms |
コンパイル使用メモリ | 177,216 KB |
実行使用メモリ | 28,500 KB |
最終ジャッジ日時 | 2023-08-21 06:47:14 |
合計ジャッジ時間 | 8,106 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 131 ms
26,340 KB |
testcase_01 | AC | 5 ms
13,724 KB |
testcase_02 | AC | 5 ms
13,912 KB |
testcase_03 | AC | 5 ms
13,680 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 153 ms
25,644 KB |
testcase_11 | AC | 132 ms
23,028 KB |
testcase_12 | AC | 133 ms
23,128 KB |
testcase_13 | AC | 115 ms
24,228 KB |
testcase_14 | AC | 543 ms
26,592 KB |
testcase_15 | AC | 535 ms
27,052 KB |
testcase_16 | AC | 513 ms
25,292 KB |
testcase_17 | AC | 521 ms
25,404 KB |
testcase_18 | AC | 547 ms
25,572 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
ソースコード
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef pair<int,int>P; int par[100000]; void init(int n){ rep(i,n)par[i]=i; } int find(int x){ if(par[x]==x)return x; return par[x]=find(par[x]); } void unite(int x,int y){ x=find(x);y=find(y); if(x==y)return; par[x]=y; } int a[200000],b[200000],c[200000],d[200000]; int l[200000],r[200000]; vector<int>v[300000]; int main(){ int n,m,q;scanf("%d%d%d",&n,&m,&q); set<P>se; rep(i,m){ scanf("%d%d",&a[i],&b[i]);a[i]--;b[i]--; se.insert(P(a[i],b[i])); } rep(i,q){ scanf("%d%d",&c[i],&d[i]);c[i]--;d[i]--; se.erase(P(c[i],d[i])); } rep(i,n){ l[i]=0;r[i]=q; } rep(i,20){ rep(j,q+1)v[j].clear(); rep(j,n){ int t=(l[j]+r[j])/2; v[t].push_back(j); } init(n); for(auto p:se)unite(p.first,p.second); for(int j=q-1;j>=0;j--){ for(int k:v[j]){ if(find(k)==find(0))l[k]=j+1; else r[k]=j; } if(j)unite(c[j],d[j]); } } init(n); rep(i,m)unite(a[i],b[i]); rep(i,n-1){ if(l[i+1]==q)puts("-1"); else if(find(i)!=find(0))puts("0"); else printf("%d\n",l[i+1]+1); } }