Submission #1043030

#TimeUsernameProblemLanguageResultExecution timeMemory
1043030ALeonidouFriend (IOI14_friend)C++17
0 / 100
1099 ms65536 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define ll int #define F first #define S second #define pb push_back #define endl "\n" #define sz(x) (ll)x.size() typedef vector <ll> vi; typedef pair <ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } vector <vi> arr, adj; ll n; vi con, hos, pro; ll solve(ll k, vi v){ // dbg(i); if (k >= n) return 0; bool ok = true; for (ll i=0; i<sz(v); i++){ //PROBLEM HERE => REUSED VARIABLE i!!!!!!!!! for (ll j = 0; j<sz(adj[v[i]]); j++){ ll c = adj[v[i]][j]; if (c == k){ ok = false; break; } } if (!ok) break; } ll ans = solve(k+1, v); if (ok){ vi new_v = v; new_v.pb(k); ans = max(ans, solve(k+1, new_v) + con[k]); } return ans; } // Find out best sample int findSample(int N,int cc[],int hh[],int pp[]){ n = N; for (ll i=0; i<n; i++){ con.pb(cc[i]); hos.pb(hh[i]); pro.pb(pp[i]); } adj.assign(n,vi()); for (ll i =1; i<n; i++){ ll c = hos[i]; if (pro[i] != 1){ adj[c].pb(i); adj[i].pb(c); } if (pro[i] != 0){ for (ll j = 0; j<sz(adj[c]); j++){ ll d = adj[c][j]; adj[d].pb(i); adj[i].pb(d); } } } arr.assign(n, vi(n,0)); for (ll i =0; i<n; i++){ for (ll j =0; j<sz(adj[i]); j++){ arr[i][j] = 1; } } ll ans = solve(0, vi()); return ans; } /* 6 13 3 6 20 10 15 0 0 0 1 1 2 2 1 0 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...