Submission #1200127

#TimeUsernameProblemLanguageResultExecution timeMemory
1200127browntoad게임 (APIO22_game)C++20
Compilation error
0 ms0 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())

namespace{
    int n, kay;
    const ll maxn = 3e4+5;
    const ll maxk = 1005;
    const ll mod = 1e9+7;
    const ll inf = (1ll<<60);
    vector<int> g[maxn];
    vector<int> rg[maxn];

    bool ioth[maxk][maxn];
    bool othi[maxk][maxn]; // walk reverse graph
}

void init(int N, int K) {
    n = N; kay = K;
    /*REP(i, k-2){
        g[i].pb(i+1);
        rg[i+1].pb(i);
    }
    REP(i, k){
        FOR(j, i, k){
            ioth[i][j] = 1;
        }
        FOR(j, 0, i+1){
            othi[i][j] = 1;
        }
    }
    */
}

bool dfs(int st, bool wh, int u){ // wh = 0: g, wh = 1, rg
    if (wh == 0){
        ioth[st][u] = 1;
        if (othi[st][u]){
            return 1;
        }
        for (auto v:g[u]){
            if (ioth[st][v]) continue;
            if (dfs(st, wh, v)) return 1;
        }
        return 0;
    }
    else{
        othi[st][u] = 1;
        if (ioth[st][u]){
            return 1;
        }
        for (auto v:rg[u]){
            if (othi[st][v]) continue;
            if (dfs(st, wh, v)) return 1;
        }
        return 0;
    }
}
int add_teleporter(int u, int v) {
    // self-loop: u = v
    if (u == v){
        if (u < kay) return 1;
        else return 0;
    }
    if (u > v) return 1;
    else return 0;

    g[u].pb(v);
    rg[v].pb(u);

    REP(i, k){
        if (!ioth[i][u] || ioth[i][v]) continue;
        if (dfs(i, 0, v)) return 1;
    }
    REP(i, k){
        if (!othi[i][v] || othi[i][u]) continue;
        if (dfs(i, 1, u)) return 1;
    }
    return 0;
}

/*
4 3 4
0 2
0 3
1 3
2 0
1 1
*/

Compilation message (stderr)

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:83:12: error: 'k' was not declared in this scope
   83 |     REP(i, k){
      |            ^
game.cpp:6:45: note: in definition of macro 'FOR'
    6 | #define FOR(i, a, b) for (int i = (a); i < (b); i++)
      |                                             ^
game.cpp:83:5: note: in expansion of macro 'REP'
   83 |     REP(i, k){
      |     ^~~
game.cpp:87:12: error: 'k' was not declared in this scope
   87 |     REP(i, k){
      |            ^
game.cpp:6:45: note: in definition of macro 'FOR'
    6 | #define FOR(i, a, b) for (int i = (a); i < (b); i++)
      |                                             ^
game.cpp:87:5: note: in expansion of macro 'REP'
   87 |     REP(i, k){
      |     ^~~