結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー yomayoma
提出日時 2020-02-12 01:00:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,519 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 168,948 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-09 02:16:59
合計ジャッジ時間 3,870 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,820 KB
testcase_01 AC 4 ms
6,944 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 4 ms
6,948 KB
testcase_04 AC 4 ms
6,948 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 4 ms
6,948 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 4 ms
6,948 KB
testcase_10 WA -
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 10 ms
7,040 KB
testcase_14 AC 11 ms
7,180 KB
testcase_15 AC 11 ms
7,424 KB
testcase_16 AC 10 ms
7,040 KB
testcase_17 AC 11 ms
7,936 KB
testcase_18 AC 26 ms
7,808 KB
testcase_19 WA -
testcase_20 AC 42 ms
9,216 KB
testcase_21 AC 65 ms
9,088 KB
testcase_22 AC 84 ms
9,856 KB
testcase_23 AC 84 ms
10,048 KB
testcase_24 AC 86 ms
9,984 KB
testcase_25 AC 87 ms
9,936 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 lowm = 1e9;
    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);
        lowm = min(lowm, m.first);
        cpre = m.second;
    }
    low[v] = lowm;
    if(low[v] >= pre[v])    bledge++;
    return make_pair(lowm, 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