結果

問題 No.768 Tapris and Noel play the game on Treeone
ユーザー lumc_lumc_
提出日時 2018-06-16 01:39:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 756 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 163,504 KB
実行使用メモリ 9,436 KB
最終ジャッジ日時 2023-10-25 21:48:26
合計ジャッジ時間 4,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 3 ms
5,884 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
20evil_special_uni1.txt WA -
20evil_special_uni2.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 木チェック
// 制約チェック : 全部WA or ACでok
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5; 
vector<int> g[N];
int n;

bool isTree() {
  bool flag[N] = {};
  function<void(int, int)> check = [&](int v, int p) {
    flag[v] = 1;
    for(int u : g[v]) if(u != p) check(u, v);
  };
  check(0, -1);
  bool all = 1;
  for(int i = 0; i < n; i++) all &= flag[i];
  return all;
}

int main() {
  cin >> n;
  assert(1 <= n && n <= N);
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    assert(1 <= a && a <= n && 1 <= b && b <= n);
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  // 余分な入力を検知できないけど, ないので(雑)
  assert(isTree());
  cout << 0 << endl;
}
0