結果

問題 No.2780 The Bottle Imp
ユーザー umezoumezo
提出日時 2024-06-19 06:20:54
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 5,700 ms
コンパイル使用メモリ 321,072 KB
実行使用メモリ 49,392 KB
最終ジャッジ日時 2024-06-19 06:21:04
合計ジャッジ時間 10,106 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 52 ms
16,984 KB
testcase_08 AC 53 ms
16,948 KB
testcase_09 AC 54 ms
16,856 KB
testcase_10 AC 56 ms
16,996 KB
testcase_11 AC 52 ms
16,856 KB
testcase_12 AC 118 ms
34,436 KB
testcase_13 AC 111 ms
34,296 KB
testcase_14 AC 19 ms
6,764 KB
testcase_15 AC 18 ms
6,896 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 18 ms
6,896 KB
testcase_19 AC 18 ms
6,896 KB
testcase_20 AC 18 ms
6,888 KB
testcase_21 WA -
testcase_22 AC 15 ms
7,008 KB
testcase_23 AC 16 ms
6,752 KB
testcase_24 AC 40 ms
14,488 KB
testcase_25 AC 89 ms
24,760 KB
testcase_26 AC 27 ms
9,520 KB
testcase_27 AC 17 ms
7,576 KB
testcase_28 AC 18 ms
7,572 KB
testcase_29 AC 35 ms
16,012 KB
testcase_30 AC 35 ms
16,392 KB
testcase_31 AC 29 ms
11,704 KB
testcase_32 AC 12 ms
5,376 KB
testcase_33 AC 42 ms
26,732 KB
testcase_34 AC 76 ms
49,392 KB
testcase_35 AC 10 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 9 ms
5,376 KB
testcase_39 AC 31 ms
14,676 KB
testcase_40 AC 29 ms
14,544 KB
testcase_41 AC 30 ms
14,548 KB
testcase_42 AC 3 ms
5,376 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint=modint998244353;//modint1000000007

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>; //B(n,V<int>(n))

V<int> A[100100];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  scc_graph g(n);
  V<int> M(n);
  rep(i,n){
    cin>>M[i];
    rep(j,M[i]){
      int a;
      cin>>a;
      a--;
      g.add_edge(i,a);
      A[i].push_back(a);
    }
  }
  auto scc=g.scc();
  V<int> G(n);
  int a=scc.size();
  rep(i,a){
    for(auto j:scc[i]) G[j]=i; 
  }
  V<set<int>> to(a),from(a);
  rep(i,n){
    for(auto x:A[i]){
      if(G[x]==G[i]) continue;
      from[G[x]].insert(G[i]);
      to[G[i]].insert(G[x]);
    }
  }
  V<int> dp(a),out(a);
  queue<int> que;
  rep(i,a){
    if(to[i].size()==0){
      que.push(i);
      dp[i]=1;
    }
    else out[i]=to[i].size();
  }
  while(que.size()){
    auto b=que.front(); que.pop();
    for(auto x:from[b]){
      dp[x]=max(dp[x],dp[b]+1);
      out[x]--;
      if(out[x]==0) que.push(x);
    }
  }
  int ma=0;
  rep(i,a) ma=max(ma,dp[i]);
  if(ma==a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
  return 0;
}
0