結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー tempura_pptempura_pp
提出日時 2019-09-24 16:33:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,046 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 105,960 KB
実行使用メモリ 11,436 KB
最終ジャッジ日時 2023-10-19 08:55:27
合計ジャッジ時間 2,694 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 10 ms
4,424 KB
testcase_15 AC 9 ms
4,412 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 31 ms
8,596 KB
testcase_20 AC 51 ms
7,804 KB
testcase_21 AC 83 ms
8,332 KB
testcase_22 AC 112 ms
9,916 KB
testcase_23 AC 113 ms
11,436 KB
testcase_24 WA -
testcase_25 AC 113 ms
11,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 LowLink {
    const vector<vector<int>> &g;
    vector< int > used, ord, low;
    vector< int > articulation;
    vector< pair< int, int > > bridge;
 
    LowLink(const vector<vector<int>> &g) : g(g) {}
 
    int dfs(int idx, int k, int par) {
        used[idx] = true;
        ord[idx] = k++;
        low[idx] = ord[idx];
        bool is_articulation = false;
        int cnt = 0;
        for(auto &to : g[idx]) {
            if(!used[to]) {
                ++cnt;
                k = dfs(to, k, idx);
                low[idx] = min(low[idx], low[to]);
                if(par!=-1&&low[to]>=ord[idx])is_articulation =true;
                if(ord[idx] < low[to]) bridge.emplace_back(minmax(idx, (int) to));
            }
            else if(to != par) {
                low[idx] = min(low[idx], ord[to]);
            }
        }
        if(par==-1&&cnt>1)is_articulation= true;
        if(is_articulation) articulation.push_back(idx);
        return k;
    }
 
    virtual int build() {
        used.assign(g.size(), 0);
        ord.assign(g.size(), 0);
        low.assign(g.size(), 0);
        int k = 0, c = 0;
        for(int i = 0; i < g.size(); i++) {
            if(!used[i])++c, k = dfs(i, k, -1);
        }
        return c;
    }
};


int main(){
    int n;
    cin>>n;
    vector<vector<int>> v(n);
    rep(i,n-1){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    LowLink ll(v);
    int ret = ll.build();
    if(ret>=3){
        cout<<"Alice"<<endl;
    }
    else cout<<"Bob"<<endl;
    return 0;
}
0