답안 #234102

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234102 2020-05-23T05:59:07 Z AM1648 경찰관과 강도 (BOI14_coprobber) C++17
30 / 100
675 ms 10776 KB
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>

using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll MAX_N = 500;
const ll maxn = 500;
const ll maxnlg = 20;

struct State {
    ll u, v, b;
};

// 0 -> robbers' turn, 1 -> cop's turn
ll C;
ll par[maxn][maxn][2];
ll deg[maxn][maxn];
State q[maxn * maxn * 2];

ll start(ll n, bool G[MAX_N][MAX_N]) {
    ll l = 0, r = 0;
    memset(par, -1, sizeof par);
    fori (i, n) {
        q[r++] = {i, i, 0};
        q[r++] = {i, i, 1};
        par[i][i][0] = par[i][i][1] = 0;
    }
    fori (i, n) {
        ll d = 0;
        fori (j, n) d += G[i][j];
        fill (deg[i], deg[i] + n, d);
    }
    while (l < r) {
        State x = q[l++];
        if (!x.b) {
            fori (i, n) {
                if (par[x.u][i][1] == -1 && (G[x.v][i] || i == x.v)) {
                    par[x.u][i][1] = x.v;
                    q[r++] = {x.u, i, 1};
                }
            }
        } else {
            fori (i, n) {
                if (par[i][x.v][0] == -1 && G[x.u][i] && --deg[i][x.v] == 0) {
                    par[i][x.v][0] = x.u;
                    q[r++] = {i, x.v, 0};
                }
            }
        }
    }
    fori (i, n) {
        bool flag = true;
        fori (j, n) {
            if (par[i][j][1] == -1) {
                flag = false;
                break;
            }
        }
        if (flag) return i;
    }
    return -1;
}

ll nextMove(ll R) {
    C = par[R][C][1];
    return C;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2304 KB Output is correct
2 Correct 6 ms 2304 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 413 ms 10776 KB Output is correct
5 Correct 80 ms 4728 KB Output is correct
6 Correct 675 ms 10488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2304 KB Output is correct
2 Correct 5 ms 2304 KB Output is correct
3 Correct 508 ms 10276 KB Output is correct
4 Correct 401 ms 10688 KB Output is correct
5 Correct 508 ms 10104 KB Output is correct
6 Correct 443 ms 10460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2304 KB Output is correct
2 Correct 5 ms 2304 KB Output is correct
3 Correct 5 ms 2304 KB Output is correct
4 Correct 5 ms 2304 KB Output is correct
5 Correct 6 ms 2432 KB Output is correct
6 Correct 6 ms 2304 KB Output is correct
7 Correct 6 ms 2304 KB Output is correct
8 Correct 6 ms 2432 KB Output is correct
9 Incorrect 6 ms 2432 KB Cop cannot catch the robber, but start() did not return -1
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2304 KB Output is correct
2 Correct 6 ms 2304 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 413 ms 10776 KB Output is correct
5 Correct 80 ms 4728 KB Output is correct
6 Correct 675 ms 10488 KB Output is correct
7 Correct 5 ms 2304 KB Output is correct
8 Correct 5 ms 2304 KB Output is correct
9 Correct 508 ms 10276 KB Output is correct
10 Correct 401 ms 10688 KB Output is correct
11 Correct 508 ms 10104 KB Output is correct
12 Correct 443 ms 10460 KB Output is correct
13 Correct 5 ms 2304 KB Output is correct
14 Correct 5 ms 2304 KB Output is correct
15 Correct 5 ms 2304 KB Output is correct
16 Correct 5 ms 2304 KB Output is correct
17 Correct 6 ms 2432 KB Output is correct
18 Correct 6 ms 2304 KB Output is correct
19 Correct 6 ms 2304 KB Output is correct
20 Correct 6 ms 2432 KB Output is correct
21 Incorrect 6 ms 2432 KB Cop cannot catch the robber, but start() did not return -1
22 Halted 0 ms 0 KB -