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 "teams.h"
# include <bits/stdc++.h>
using namespace std;
int n, mt[100005], used[100005];
vector <int> a, b, g[100005];
void init(int N, int A[], int B[]) {
n = N;
for(int i = 0; i < n; i ++)
a.push_back(A[i]), b.push_back(B[i]);
}
bool kuhn(int v){
if(used[v]) return false;
used[v] = 1;
for(int to : g[v]){
if(mt[to] == -1 || kuhn(mt[to])){
mt[to] = v;
return true;
}
}
return false;
}
int can(int M, int K[]) {
int sum = 0;
for(int i = 0; i < M; i ++)
sum += K[i];
if(sum > n) return 0;
for(int i = 0; i < n; i ++)
g[i].clear();
for(int i = 0; i < n; i ++){
int pref = 0;
for(int j = 0; j < M; j ++){
if(a[i] <= K[j] <= b[i]){
for(int k = pref; k < pref + K[j]; k ++){
g[i].push_back(k + n),
g[k + n].push_back(i);
}
}
pref += K[j];
}
}
for(int i = 0; i < n + M; i ++)
mt[i] = -1;
for(int i = 0; i < n; i ++){
memset(used, 0, sizeof(used));
kuhn(i);
}
for(int i = 0; i < n; i ++){
if(mt[i] != -1) sum --;
}
if(!sum) return 1;
return 0;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:37:27: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
if(a[i] <= K[j] <= b[i]){
# | 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... |