제출 #1040083

#제출 시각아이디문제언어결과실행 시간메모리
1040083ProtonDecay314친구 (IOI14_friend)C++17
0 / 100
0 ms348 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; int ans = 0; for(int s = 0; s < n; s++) { if(!vis[s]) { int num1 = 0; q.push({s, 0}); while(!q.empty()) { auto [i, c] = q.front(); q.pop(); if(vis[i]) continue; vis[i] = true; num1 += c; for(int j : adj[i]) { if(vis[j]) continue; q.push({j, 1 - c}); } } ans += max(num1, n - num1); } } return ans; }
#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...