Submission #280477

#TimeUsernameProblemLanguageResultExecution timeMemory
280477ajpianoFriend (IOI14_friend)C++17
0 / 100
1084 ms384 KiB
#include <bits/stdc++.h> #include <friend.h> #pragma GCC optimize("O3") #pragma GCC target("sse4") using namespace std; #define FOR(a,b) for(int a=0;a<b;a++) #define F0R(a,b,c) for(int a = b; a<=c; a++) #define f first #define s second #define m0(x) memset(x,0,sizeof(x)) typedef pair<int,int> pi; typedef long long ll; typedef vector<int> vi; typedef vector<pi> vpi; int findSample(int n, int conf[], int host[], int pr[]){ vi edges[n]; F0R(i,1,n-1){ int h = host[i]; if(pr[i] == 0){ edges[i].push_back(h); }else{ if(pr[i] == 2) edges[i].push_back(h); for(auto &a: edges[h]) edges[i].push_back(a); } } int best = 0; FOR(mask,(1<<n)){ int cur = 0; bool good = 1; vector<bool> found(n); FOR(i,n){ if((1<<i)&mask){ cur += conf[i]; found[i] = 1; } } if(cur <= best) continue; FOR(i,n){ if(!found[i]) continue; for(auto &a: edges[i]){ if(found[a]){ good = 0; break; } } if(!good) break; } if(good) best = cur; } return best; } // //void grader(){ // int n; cin >> n; // int conf[n],host[n],pr[n]; // FOR(i,n) cin >> conf[i]; // F0R(i,1,n-1) cin >> host[i] >> pr[i]; // cout << "Answer: " << findSample(n,conf,host,pr); //} // //int main() //{ // ios_base::sync_with_stdio(0); cin.tie(0); // grader(); // 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...
#Verdict Execution timeMemoryGrader output
Fetching results...