# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117502 | zubec | Teams (IOI15_teams) | C++14 | 1588 ms | 524288 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 "teams.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500100;
vector <int> g[N];
pair<int, int> a[N];
int n;
void init(int N, int A[], int B[]) {
n = N;
for (int i = 1; i <= n; i++){
a[i] = {A[i-1], B[i-1]};
}
}
bool used[N];
int mt[N];
int try_khun(int v){
if (used[v])
return 0;
used[v] = 1;
for (int i = 0; i < g[v].size(); i++){
int to = g[v][i];
if (mt[to] == -1 || try_khun(mt[to])){
mt[to] = v;
return 1;
}
}
return 0;
}
int can(int M, int K[]) {
ll sum = 0;
for (int i = 1; i <= M; i++){
sum += K[i-1];
}
if (sum > n)
return 0;
for (int i = 1; i <= n+sum; i++){
g[i].clear();
mt[i] = -1;
}
int kol = n;
for (int i = 1; i <= M; i++){
for (int j = 1; j <= n; j++){
if (a[j].first <= K[i-1] && K[i-1] <= a[j].second){
for (int l = 1; l <= K[i-1]; l++){
g[j].push_back(kol+l);
g[kol+l].push_back(j);
}
}
}
kol += K[i-1];
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n+sum; j++)
used[j] = 0;
try_khun(i);
}
for (int i = n+1; i <= n+sum; i++){
if (mt[i] == -1)
return 0;
}
return 1;
}
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... |