Submission #633413

#TimeUsernameProblemLanguageResultExecution timeMemory
633413ghostwriterGame (IOI14_game)C++14
100 / 100
381 ms25260 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#include "grader.cpp"
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Practising for VOI23 gold medal
*/
const int N = 1501;
int n, p[N], d[N][N];
int getp(int i) { return i == p[i]? i : p[i] = getp(p[i]); }
void initialize(int n) {
    ::n = n;
    FOR(i, 0, n - 1) {
        p[i] = i;
        FOR(j, 0, n - 1) d[i][j] = 1;
    }
}
int hasEdge(int u, int v) {
    u = getp(u);
    v = getp(v);
    if (d[u][v] > 1) {
        --d[u][v];
        --d[v][u];
        return 0;
    }
    p[v] = u;
    FOR(i, 0, n - 1) {
        d[u][i] += d[v][i];
        d[i][u] += d[v][i];
    }
    return 1;
}

Compilation message (stderr)

game.cpp: In function 'void initialize(int)':
game.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
game.cpp:43:5: note: in expansion of macro 'FOR'
   43 |     FOR(i, 0, n - 1) {
      |     ^~~
game.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
game.cpp:45:9: note: in expansion of macro 'FOR'
   45 |         FOR(j, 0, n - 1) d[i][j] = 1;
      |         ^~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
game.cpp:57:5: note: in expansion of macro 'FOR'
   57 |     FOR(i, 0, n - 1) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...