Submission #1040079

#TimeUsernameProblemLanguageResultExecution timeMemory
1040079ProtonDecay314Friend (IOI14_friend)C++17
0 / 100
1 ms448 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef vector<vpi> vvpi; typedef vector<vpll> vvpll; typedef vector<bool> vb; #define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++) #define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--) #define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++) #define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--) #define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci #define fi first #define se second #define pb push_back #define INF(type) numeric_limits<type>::max() #define NINF(type) numeric_limits<type>::min() #define TCASES int t; cin >> t; while(t--) // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ vvi adj; for(int i = 0; i < n; i++) { vi adjr; adj.pb(adjr); } for(int i = 1; i < n; i++) { if(protocol[i] == 0) { // I am your friend adj[i].pb(host[i]); adj[host[i]].pb(i); } else if(protocol[i] == 1) { // My friends are your friends for(int j : adj[host[i]]) { adj[i].pb(j); adj[j].pb(i); } } } vb vis(n, false); queue<pi> q; q.push({0, 0}); int num0 = 0; while(!q.empty()) { auto [i, c] = q.front(); q.pop(); if(vis[i]) continue; vis[i] = true; if(c == 0) num0++; for(int j : adj[i]) { if(vis[j]) continue; q.push({j, 1 - c}); } } return max(num0, n - num0); }
#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...