Submission #165418

#TimeUsernameProblemLanguageResultExecution timeMemory
165418gaypornRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
//Pye
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define pair pair <int, int>
#define F first
#define S second
#define maxn 20005
using namespace std;
int A, B, T, z, tr[maxn], cnt, s, t, maxflow;
pair q[maxn];
struct edge{
    int u, v, c, f;
}e[2*maxn];
vector <int> a[maxn];
void add(int u, int v, int c){
    a[u].push_back(z);
    e[z++] = {u, v, c, 0};
    a[v].push_back(z);
    e[z++] = {v, u, 0, 0};
}
bool BFS(){
    memset(tr, 0, sizeof tr);
    tr[s] = -1;
    queue <int> q;
    q.push(s);
    while (q.size()){
        int u = q.front(); q.pop();
        for (auto id : a[u]){
            int v = e[id].v;
            if (!tr[v] && e[id].c > e[id].f){
                tr[v] = id;
                q.push(v);
                if(v == t) return 1;
            }
        }
    }
    return 0;
}
void IncFlow(){
    int delta = 1e9;
    int v = t;
    while (v != s){
        int id = tr[v];
        delta = min(delta, e[id].c - e[id].f);
        v = e[id].u;
    }
    v = t;
    while (v != s){
        int id = tr[v];
        e[id].f += delta;
        e[id^1].f -= delta;
        v = e[id].u;
    }
    maxflow += delta;
}
bool check(int mid){
    for(int i = 0; i < 2*(A + B); i += 2) e[i].c = mid;
    for(int i = 0; i < z; i++) e[i].f = 0;
    maxflow = 0;
    while(BFS()) IncFlow();
    return maxflow == T;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    ifstream cin("robots.inp");
//    ofstream cout("robots.out");
    cin >> A >> B >> T;
    s = 10005; t = s+1;
    FOR(i, 1, A){
        int x; cin >> x;
        q[++cnt] = {x, 1e9};
        add(s, cnt, 0);
    }
    FOR(i, 1, B){
        int x; cin >> x;
        q[++cnt] = {1e9, x};
        add(s, cnt, 0);
    }
    FOR(i, 1, T){
        ++cnt;
        int x, y;
        cin >> x >> y;
        FOR(j, 1, A+B)
            if(q[j].F >= x && q[j].S >= y) add(j, cnt, 1);
        add(cnt, t, 1);
    }

    int l = 0, r = 1e9;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(check(mid)) r = mid;
        else l = mid;
    }
    cout << r;
}

Compilation message (stderr)

/tmp/cc3EtU7L.o: In function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccSM5C31.o:grader.c:(.text.startup+0x0): first defined here
/tmp/ccSM5C31.o: In function `main':
grader.c:(.text.startup+0x17e): undefined reference to `putaway'
collect2: error: ld returned 1 exit status