이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cout << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 1e3 + 10;
int col[maxn], match[maxn];
vector<int> g[maxn];
bool vis[maxn];
bool dfs(int v){
vis[v] = true;
for (auto u: g[v]){
if (match[u] == -1 || (!vis[match[u]] && dfs(match[u]))){
match[u] = v;
return true;
}
}
return false;
}
// Find out best sample
int findSample(int n,int w[],int p[],int t[]){
memset(match, -1, sizeof match);
for (int i = 1; i < n; i++){
if (t[i] == 2) return -1;
if (t[i] == 0){
col[i] = 1 - col[p[i]];
g[p[i]].push_back(i);
g[i].push_back(p[i]);
continue;
}
col[i] = col[p[i]];
for (auto u: g[p[i]]){
g[u].push_back(i);
g[i].push_back(u);
}
}
int ans = 0;
for (int i = 0; i < n; i++){
if (col[i] == 1) continue;
memset(vis, false, sizeof vis);
ans += dfs(i);
}
return n-ans;
}
# | 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... |