結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー yomayoma
提出日時 2020-02-12 01:33:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,500 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 169,364 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-09 03:07:05
合計ジャッジ時間 3,446 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,816 KB
testcase_01 AC 4 ms
6,952 KB
testcase_02 AC 4 ms
7,040 KB
testcase_03 AC 3 ms
6,948 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 4 ms
6,948 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 4 ms
6,948 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 3 ms
6,948 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 5 ms
6,948 KB
testcase_13 AC 12 ms
7,168 KB
testcase_14 AC 11 ms
7,296 KB
testcase_15 AC 12 ms
7,296 KB
testcase_16 AC 11 ms
7,040 KB
testcase_17 WA -
testcase_18 AC 28 ms
7,808 KB
testcase_19 AC 30 ms
9,984 KB
testcase_20 AC 47 ms
9,088 KB
testcase_21 AC 76 ms
9,088 KB
testcase_22 AC 102 ms
9,856 KB
testcase_23 AC 99 ms
9,984 KB
testcase_24 AC 98 ms
9,984 KB
testcase_25 AC 102 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<vector<int>> G(1e5);
vector<int> used(1e5), pre(1e5), low(1e5);
int bledge = 0;

pair<int, int> dfs(int v, int vpre){
    used[v] = 1;
    int cpre = vpre;
    pre[v] = low[v] = cpre;
    for(auto g : G[v]){
        if(used[g]){
            if(pre[g] != vpre-1)    low[v] = min(low[v], low[g]);
            continue;
        }
        cpre++;
        pair<int, int> m = dfs(g, cpre);
        low[v] = min(low[v], m.first);
        cpre = m.second;
    }
    if(low[v] >= pre[v] && pre[v] > 0)    bledge++;
    return make_pair(low[v], cpre);
}
int main(){
    int N;
    cin >> N;
    for(int i = 0;i < N-1;i++){
        int ui, vi;
        cin >> ui >> vi;
        G[ui].push_back(vi);
        G[vi].push_back(ui);
    }
    int cnt = 0;
    for(int i = 0;i < N;i++){
        if(used[i]) continue;
        cnt++;
        dfs(i, 0);
    }
    if(cnt >= 3)    cout << "Alice" << endl;
    else if(cnt == 2){
        if(bledge > 0)  cout << "Alice" << endl;
        else    cout << "Bob" << endl;
    }else   cout << "Bob" << endl;
}
0