結果

問題 No.977 アリス仕掛けの摩天楼
コンテスト
ユーザー trineutron
提出日時 2020-02-04 14:21:26
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 709 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,019 ms
コンパイル使用メモリ 187,360 KB
実行使用メモリ 1,302,400 KB
最終ジャッジ日時 2026-04-09 14:16:55
合計ジャッジ時間 19,021 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 13 TLE * 5 MLE * 2 -- * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:19:14: warning: 'u' may be used uninitialized [-Wmaybe-uninitialized]
   19 |         to.at(u).push_back(v);
      |         ~~~~~^~~
main.cpp:18:13: note: 'u' declared here
   18 |         int u, v;
      |             ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bitset:54,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
In member function 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]',
    inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/alloc_traits.h:674:17,
    inlined from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:1421:30,
    inlined from 'int main()' at main.cpp:19:27:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/new_allocator.h:191:11: warning: 'v' may be used uninitialized [-Wmaybe-uninitialized]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:18:16: note: 'v' declared here
   18 |         int u, v;
      |                ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

bool dfs(const vector<vector<int>> &to, vector<bool> &isvisited, int index, int prev) {
    for (int next : to.at(index)) {
        if (next == prev) continue;
        if (isvisited.at(next)) return false;
        if (dfs(to, isvisited, next, index) == false) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> to(n, vector<int>(n));
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        to.at(u).push_back(v);
        to.at(v).push_back(u);
    }
    vector<bool> isvisited(n);
    if (dfs(to, isvisited, 0, -1)) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
}
0