Submission #915260

#TimeUsernameProblemLanguageResultExecution timeMemory
9152603as8Viruses (BOI20_viruses)C++14
0 / 100
165 ms262144 KiB
#include <bits/stdc++.h> #define ll long long #define endl "\n" #define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); #define mid ((l + r) / 2) #define lChild ((index * 2) + 1) #define rChild ((index * 2) + 2) using namespace std; struct edge { ll u, c; }; vector<ll> dp(3000, -1); vector<bool> cn(3000, 0); ll get(vector<vector<ll> >& graph, vector<vector<ll> >& ind, vector<ll>& num, ll startIndex, ll p, ll value) { // cout<<startIndex<<endl; ll ans = num[startIndex]; bool can = true; for(auto el : graph[startIndex]) { if(el == value) { can = false; continue; } //cout<<" => "<<el<<endl; if(dp[el] == -1) { ll mn = LLONG_MAX; for (auto it: ind[el]) { mn = min(mn, get(graph, ind, num, it, startIndex, el)); } dp[el] = mn; } ans += dp[el]; } // cout<<"dp["<<value<<"] ="<<ans<<endl; if(!can) return -1; return dp[value] = ans; } void solve(ll _) { ll g, n, m; cin>>g>>n>>m; vector<vector<ll> > graph(n + 5); vector<ll> rev(g + 1); vector<vector<ll> > ind(g + 1); vector<bool> cn(n, false); ll t = -1; vector<ll> num(n); for(int i = 0; i < n; i++) { ll a; cin>>a; ll k; cin>>k; ind[a].push_back(i); rev[i] = a; ll w = 0; bool can = true; bool has = false; for(int j = 0; j < k; j++) { ll x; cin>>x; if(x == 1 || x == 0) { w += 1; continue; } can = false; if(x == a) has= true; graph[i].push_back(x); } cn[a] = cn[a] | !has; // cout<<"a: "<<w<<endl; num[i] = w; } for(int i = 0; i < n; i++) { get(graph, ind, num, i , -1, rev[i]); } for(int i = 2; i <= g; i++) { if(!cn[i]) cout<<"YES"<<endl; else cout<<"NO "<<dp[i]<<endl; } } int main() { fastIO //freopen("file.in", "r", stdin); //freopen("file.out", "w", stdout); ll t = 0; solve(t); }

Compilation message (stderr)

Viruses.cpp: In function 'void solve(long long int)':
Viruses.cpp:76:14: warning: variable 'can' set but not used [-Wunused-but-set-variable]
   76 |         bool can = true;
      |              ^~~
Viruses.cpp:67:8: warning: unused variable 't' [-Wunused-variable]
   67 |     ll t = -1;
      |        ^
#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...