Submission #780991

#TimeUsernameProblemLanguageResultExecution timeMemory
780991fatemetmhrFriend (IOI14_friend)C++17
58 / 100
36 ms15552 KiB
// ~ Be Name Khoda ~ // #include "friend.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; int cmp[maxn5], hs[maxn5], ty[maxn5]; ll val[maxn5][2]; int n, dp[maxn5][2], mat[maxn5]; vector <int> adj[maxn5]; bool mark[maxn5]; // Find out best sample int findSample(int n,int confidence[], int host[], int protocol[]){ ::n = n; for(int i = 1; i < n; i++){ val[i][1] = confidence[i]; hs[i] = host[i]; ty[i] = protocol[i]; } val[0][1] = confidence[0]; for(int i = n - 1; i; i--){ int v = hs[i]; if(ty[i] == 0){ val[v][0] += max(val[i][0], val[i][1]); val[v][1] += val[i][0]; } if(ty[i] == 1){ val[v][0] += val[i][0]; val[v][1] += val[i][1]; } if(ty[i] == 2){ val[v][0] += val[i][0]; val[v][1] = max(val[v][1] + val[i][0], val[i][1]); } val[v][1] = max(val[v][1], val[v][0]); //for(int j = 0; j < n; j++) // cout << i << ' ' << j << ' ' << val[j][0] << ' ' << val[j][1] << endl; } return max(val[0][0], val[0][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...
#Verdict Execution timeMemoryGrader output
Fetching results...