Submission #915134

#TimeUsernameProblemLanguageResultExecution timeMemory
915134AbitoViruses (BOI20_viruses)C++14
0 / 100
1085 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]; void dfs(int x){ vis[x]=true; for (auto u:adj[x]){ if (vis[u]) continue; dfs(u); }return; } int rec(int x){ vis[x]=true; dp[x]=INT_MAX; for (auto u:mut[x]){ bool ok=true; for (auto v:u){ if (comp[v][x]){ ok=false;break; } }if (!ok) continue; int z=0; for (auto v:u){ if (v<2) z++; else z+=rec(v); }dp[x]=min(dp[x],z); }return dp[x]; } 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++){ for (int j=2;j<g;j++){ dfs(i); bool x=vis[j]; memset(vis,0,sizeof(vis)); if (!x) continue; dfs(j); bool y=vis[i]; memset(vis,0,sizeof(vis)); if (!y) continue; comp[i][j]=true; //cout<<i<<' '<<j<<endl; } } for (int i=2;i<g;i++){ int x=rec(i); if (x==INT_MAX) 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...