# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404179 | peuch | Friend (IOI14_friend) | C++17 | 2 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
int dp[MAXN][2];
int v[MAXN];
int cor[MAXN];
int marcB[MAXN];
int match[MAXN];
vector<int> ar[MAXN];
vector<int> grp[2];
bool dfs(int cur);
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i = 0; i < n; i++)
v[i] = confidence[i];
grp[0].push_back(0);
cor[0] = 0;
for(int i = 1; i < n; i++){
if(protocol[i] == 0){
ar[host[i]].push_back(i);
ar[i].push_back(host[i]);
cor[i] = !cor[host[i]];
grp[cor[i]].push_back(i);
}
else{
for(int j = 0; j < ar[host[i]].size(); j++){
ar[ar[host[i]][j]].push_back(i);
ar[i].push_back(ar[host[i]][j]);
}
cor[i] = cor[host[i]];
grp[cor[i]].push_back(i);
}
}
for(int i = 0; i < n; i++)
match[i] = -1;
bool flag = true;
int ans = 0;
while(flag){
flag = false;
for(int i = 0; i < n; i++) marcB[i] = 0;
for(int i = 0; i < grp[0].size(); i++){
int cur = grp[0][i];
if(match[cur] != -1) continue;
if(dfs(cur)){
flag = true;
ans++;
}
}
}
ans = n - ans;
return ans;
}
bool dfs(int cur){
for(int i = 0; i < ar[cur].size(); i++) {
int viz = ar[cur][i];
if(marcB[viz]) continue;
marcB[viz] = 1;
if(match[viz] == -1 || dfs(match[viz])){
match[cur] = viz;
match[viz] = cur;
return true;
}
}
return false;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |