結果

問題 No.2780 The Bottle Imp
ユーザー friedrice
提出日時 2024-11-11 22:14:39
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 670 bytes
コンパイル時間 3,625 ms
コンパイル使用メモリ 255,616 KB
実行使用メモリ 13,768 KB
最終ジャッジ日時 2024-11-11 22:14:48
合計ジャッジ時間 9,188 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 TLE * 1 -- * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int N;
bool ans = false;
vector<vector<int>> To;
vector<bool> seen(100001, false);
void dfs(int v, int l) {
  if(l == N) {
    ans = true;
    return;
  }
  seen.at(v) = true;
  for(int next_v : To.at(v)) {
    if(seen.at(next_v)) {
      continue;
    }
    dfs(next_v, l + 1);
  }
  seen.at(v) = false;
}

int main() {
  cin >> N;
  int M;
  To.assign(N + 1, vector<int>(0, 0));
  for(int i = 1; i <= N; i++) {
    cin >> M;
    int A;
    for(int j = 0; j < M; j++) {
      cin >> A;
      To.at(i).push_back(A);
    }
  }
  dfs(1, 1);
  if(ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
0