Submission #915204

#TimeUsernameProblemLanguageResultExecution timeMemory
915204AbitoViruses (BOI20_viruses)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long #define y1 YONE #define free freeee #define lcm llcm /* ⠄⠄⠄⠄⢠⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣿⣿⣯⢻⣿⣿⣿⣿⣆⠄⠄⠄ ⠄⠄⣼⢀⣿⣿⣿⣿⣏⡏⠄⠹⣿⣿⣿⣿⣿⣿⣿⣿⣧⢻⣿⣿⣿⣿⡆⠄⠄ ⠄⠄⡟⣼⣿⣿⣿⣿⣿⠄⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⣿⣇⢻⣿⣿⣿⣿⠄⠄ ⠄⢰⠃⣿⣿⠿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠙⠿⣿⣿⣿⣿⣿⠄⢿⣿⣿⣿⡄⠄ ⠄⢸⢠⣿⣿⣧⡙⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠈⠛⢿⣿⣿⡇⠸⣿⡿⣸⡇⠄ ⠄⠈⡆⣿⣿⣿⣿⣦⡙⠳⠄⠄⠄⠄⠄⠄⢀⣠⣤⣀⣈⠙⠃⠄⠿⢇⣿⡇⠄ ⠄⠄⡇⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⣠⣶⣿⣿⣿⣿⣿⣿⣷⣆⡀⣼⣿⡇⠄ ⠄⠄⢹⡘⣿⣿⣿⢿⣷⡀⠄⢀⣴⣾⣟⠉⠉⠉⠉⣽⣿⣿⣿⣿⠇⢹⣿⠃⠄ ⠄⠄⠄⢷⡘⢿⣿⣎⢻⣷⠰⣿⣿⣿⣿⣦⣀⣀⣴⣿⣿⣿⠟⢫⡾⢸⡟⠄. ⠄⠄⠄⠄⠻⣦⡙⠿⣧⠙⢷⠙⠻⠿⢿⡿⠿⠿⠛⠋⠉⠄⠂⠘⠁⠞⠄⠄⠄ ⠄⠄⠄⠄⠄⠈⠙⠑⣠⣤⣴⡖⠄⠿⣋⣉⣉⡁⠄⢾⣦⠄⠄⠄⠄⠄⠄⠄⠄ */ typedef unsigned long long ull; using namespace std; const int N=1e3+5; int g,n,m,dp[N]; vector<int> adj[N]; vector<vector<int>> mut[N]; bool comp[N][N],vis[N][N],calc[N]; void dfs(int x,int s){ vis[s][x]=true; for (auto u:adj[x]){ if (vis[s][u]) continue; dfs(u,s); }return; } int rec(int x){ if (calc[x]) return dp[x]; calc[x]=true; dp[x]=-1;int ans=-1; for (auto u:mut[x]){ int z=0; for (auto v:u){ if (v<2) { z++; continue; }int h=rec(v); if (h==-1) {z=-1;break;} else z+=h; } if (ans==-1) ans=z; elif (z>-1) ans=min(ans,z); }return dp[x]=ans; } int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>g>>n>>m; for (int i=1;i<=n;i++){ int x,k;cin>>x>>k; vector<int> v(k); for (int j=0;j<k;j++){ cin>>v[j]; if (v[j]>1) adj[x].pb(v[j]); } mut[x].pb(v); } for (int i=2;i<g;i++) dfs(i,i); for (int i=2;i<g;i++){ int x=rec(i); if (x==-1) cout<<"YES"<<endl; else cout<<"NO "<<x<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...