Submission #1070820

#TimeUsernameProblemLanguageResultExecution timeMemory
1070820ortsacCop and Robber (BOI14_coprobber)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h>
#include "coprobber.h"

using namespace std;

int atual = 0;
int n;

vector<vector<int>> adj;
int col = 0x3f3f3f3f;
int row;

int x[] = {-1, -1, 1, 1};
int y[] = {-1, 1, -1, 1};

int start(int N, bool A[MAX_N][MAX_N]) {
    // realmente não importa qual posição ele inicia
    // pq ele pode só ir andando pra qualquer uma e o cara escolhe de qualquer jeito então fodase
    n = N;
    adj.resize(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (A[i][j]) adj[i].push_back(j);
        }
    }
    for (int i = 1; i < n; i++) {
        if (adj[i].size() == 2) {
            col = i + 1;
            break;
        }
    }
    row = n/col;
    return 0;
}

bool gCell(int i, int j) {
    return i*col + j;
}

int nextMove(int r) { // IDEALMENTE O(N)
    int iR = r/col, jR = r%col;
    int iA = atual/col, jA = atual%col;
    // R is in corner
    if (((iR % (row - 1)) == 0) && ((jR % (col - 1)) == 0)) {
        for (int k = 0; k < 4; k++) {
            if (make_pair(iA + x[k], jA + y[k]) == make_pair(iR, jR)) {
                return atual;
            }
        }
    }
    // notInCorner
    if (iA > iR) {
        return (atual = gCell(iA - 1, jA));
    } else if (iA < iR) {
        return (atual = gCell(iA + 1, jA));
    } else if (jA > jR) {
        return (atual = gCell(iA, jA - 1));
    } else {
        return (atual = gCell(iA, jA + 1));
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...