結果
| 問題 |
No.2780 The Bottle Imp
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-06-07 21:40:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 4,339 ms |
| コンパイル使用メモリ | 255,824 KB |
| 最終ジャッジ日時 | 2025-02-21 20:02:48 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
int n;
cin>>n;
vector<vector<int>> E(n);
scc_graph S(n);
rep(i,n){
int m;
cin>>m;
rep(j,m){
int a;
cin>>a;
a--;
E[i].push_back(a);
S.add_edge(i,a);
}
}
auto s = S.scc();
vector<int> pos(n);
rep(i,s.size()){
for(auto x:s[i]){
pos[x] = i;
}
}
if(pos[0]!=0){
cout<<"No"<<endl;
return 0;
}
rep(i,s.size()-1){
bool f = false;
rep(j,s[i].size()){
rep(k,E[s[i][j]].size()){
if(pos[E[s[i][j]][k]]==i+1){
f = true;
break;
}
}
}if(!f){
cout<<"No"<<endl;
return 0;
}
}
cout<<"Yes"<<endl;
return 0;
}
沙耶花