Submission #87265

# Submission time Handle Problem Language Result Execution time Memory
87265 2018-11-30T06:32:15 Z Yaroslaff Marriage questions (IZhO14_marriage) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
//#define int ll
#define x1 epgjoijhgoj
#define y1 epggoijhgoj
#define ld double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC

using namespace std;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int M = 1e9 + 7;
const int MOD = 998244353;
const int N = 1e5 + 10;

int n, m, k, x, y, l, r, us[N], u[N], cur, res, p[N];
vector<int> g[N], mt(N, -1);

bool par(int v) {
    for (int i = p[v]; i < g[v].size(); i++) {
        int to = g[v][i];
        if (to < l) p[v]++;
        if (to >= r) return 0;
        if (us[to] || to < l) continue;
        us[to] = 1;
        if (mt[to] == -1 || par(mt[to])) {
            mt[to] = v;
            return 1;
        }
    }
    return 0;
}

void kun() {
    us.assign(n + 2, -1);
    for (int i = 0; i < m; i++) {
        if (!u[i] && par(i)) {
            u[i] = 1;
            cur++;
            return;
        }
    }
}

void add() {
    ++r;
    kun();
}

void del() {
    if (mt[l] != -1) {
        u[mt[l]] = 0;
        --cur;
    }
    l++;
    if (cur < m) kun();
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        cin >> x >> y;--x;--y;
        g[y].pb(x);
    }
    for (int i = 0; i < N; i++)
        sort(g[i].begin(), g[i].end());
    for (; 1;) {
        while (r < n && cur < m) add();
        if (cur != m) break;
        res += n - r + 1;
        del();
    }
    cout << res;
    return 0;
}

Compilation message

marriage.cpp: In function 'bool par(int)':
marriage.cpp:26:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = p[v]; i < g[v].size(); i++) {
                        ~~^~~~~~~~~~~~~
marriage.cpp: In function 'void kun()':
marriage.cpp:41:8: error: request for member 'assign' in 'us', which is of non-class type 'int [100010]'
     us.assign(n + 2, -1);
        ^~~~~~
marriage.cpp: At global scope:
marriage.cpp:65:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^