結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
tempura_pp
|
| 提出日時 | 2019-09-23 21:11:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,467 bytes |
| コンパイル時間 | 808 ms |
| コンパイル使用メモリ | 100,392 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-09-19 04:33:47 |
| 合計ジャッジ時間 | 5,712 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 TLE * 1 -- * 6 |
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
struct UnionFind{
vector<int> par;
UnionFind(int n):par(n,-1){}
int find(int x){
if(par[x]<0)return x;
return par[x]=find(par[x]);
}
bool unite(int x,int y){
x=find(x);
y=find(y);
if(x==y)return false;
if(par[x]>par[y]){
par[y]+=par[x];
par[x]=y;
}
else{
par[x]+=par[y];
par[y]=x;
}
return true;
}
bool same(int x,int y){
return find(x)==find(y);
}
int size(int x){
return -par[find(x)];
}
};
int main(){
int n;
cin>>n;
vector<pair<int,int>> v(n-1);
rep(i,n-1){
cin>>v[i].first>>v[i].second;
}
rep(i,n-1){
UnionFind uf(n);
int cnt = n;
rep(j,n-1){
if(j==i)continue;
if(uf.unite(v[j].first,v[j].second))--cnt;
}
if(cnt>=3){
cout<<"Alice"<<endl;
return 0;
}
}
cout<<"Bob"<<endl;
return 0;
}
tempura_pp