結果
問題 | No.2780 The Bottle Imp |
ユーザー |
![]() |
提出日時 | 2024-06-07 21:40:56 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 844 bytes |
コンパイル時間 | 4,761 ms |
コンパイル使用メモリ | 267,804 KB |
実行使用メモリ | 31,296 KB |
最終ジャッジ日時 | 2024-12-27 13:36:33 |
合計ジャッジ時間 | 7,663 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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 1000000000000000001int 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;}