답안 #960915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960915 2024-04-11T08:27:37 Z alextodoran 길고양이 (JOI20_stray) C++17
0 / 100
43 ms 18576 KB
#include <bits/stdc++.h>
#include "Anthony.h"

using namespace std;

namespace {

const int N_MAX = 20000;
const int pattern[] = {0, 1, 0, 0, 1, 1};

int N, M, A, B;
int edge_u[N_MAX], edge_v[N_MAX];
vector <int> adj[N_MAX];
int other (int i, int u) {
    return (u != edge_v[i] ? edge_v[i] : edge_u[i]);
}

int up_edge[N_MAX];
int color[N_MAX + 1];

void dfs (int u, int chain = -1) {
    if ((int) adj[u].size() == 2 && u != 0) {
        if (chain == -1) {
            chain = 1 - color[up_edge[u]];
        } else {
            chain++;
        }
    } else {
        chain = -1;
    }
    for (int i : adj[u]) {
        if (i != up_edge[u]) {
            int v = other(i, u);
            up_edge[v] = i;
            color[i] = (chain == -1 ? 1 - color[up_edge[u]] : pattern[chain % 6]);
            dfs(v, chain);
        }
    }
}
void dfs () {
    up_edge[0] = N;
    color[0] = 0;
    dfs(0);
}

}

vector <int> Mark (int _N, int _M, int _A, int _B, vector <int> _U, vector <int> _V) {
    N = _N; M = _M; A = _A; B = _B;
    assert(M == N - 1);
    for (int i = 0; i < M; i++) {
        edge_u[i] = _U[i]; edge_v[i] = _V[i];
        adj[edge_u[i]].push_back(i);
        adj[edge_v[i]].push_back(i);
    }
    dfs();
    vector <int> X(M);
    copy(color, color + M, X.begin());
    return X;
}
#include <bits/stdc++.h>
#include "Catherine.h"

using namespace std;

namespace {
    vector <int> cols;
    bool passed_test = false;
}

int A, B;

void Init (int _A, int _B) {
    A = _A; B = _B;
}

int Move (vector <int> cnt_col) {
    int now = (cols.empty() == false ? 1 - cols.back() : 0);
    if (cnt_col[now] > 0) {
        cols.push_back(now);
    } else if (cnt_col[1 - now] > 0) {
        cols.push_back(1 - now);
    } else {
        passed_test = true;
        cols = {cols.back()};
        return -1;
    }
    if (cnt_col[cols.back()] > 1) {
        if ((int) cols.size() == 1) {
            cols.back() = 1 - cols.back();
        } else {
            passed_test = true;
            cols = {cols.back()};
            return -1;
        }
    }
    if (passed_test == false && (int) cols.size() == 6) {
        passed_test = true;
        bool ok;
        for (int i = 0; i < (int) cols.size(); i++) {
            if (cols[i] == 0 && cols[(i + 1) % 6] == 0) {
                ok = (cols[(i + 2) % 6] != cols[(i + 3) % 6]);
            }
        }
        if (ok == false) {
            cols.pop_back();
            cols = {cols.back()};
            return -1;
        }
    }
    return cols.back();
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:45:9: warning: 'ok' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |         if (ok == false) {
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 16368 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 28 ms 15388 KB Output is correct
4 Correct 38 ms 18576 KB Output is correct
5 Incorrect 27 ms 17480 KB Wrong Answer [5]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 16368 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 28 ms 15388 KB Output is correct
4 Correct 38 ms 18576 KB Output is correct
5 Incorrect 27 ms 17480 KB Wrong Answer [5]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 13932 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 32 ms 12876 KB Output is correct
4 Correct 43 ms 15824 KB Output is correct
5 Incorrect 27 ms 14708 KB Wrong Answer [5]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 13932 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 32 ms 12876 KB Output is correct
4 Correct 43 ms 15824 KB Output is correct
5 Incorrect 27 ms 14708 KB Wrong Answer [5]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1564 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 1 ms 1568 KB Output is correct
4 Correct 2 ms 1560 KB Output is correct
5 Correct 2 ms 1552 KB Output is correct
6 Incorrect 2 ms 1556 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 11344 KB Output is correct
2 Correct 27 ms 12660 KB Output is correct
3 Correct 1 ms 1308 KB Output is correct
4 Correct 27 ms 11100 KB Output is correct
5 Correct 36 ms 14360 KB Output is correct
6 Incorrect 30 ms 13216 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 11384 KB Output is correct
2 Correct 27 ms 12664 KB Output is correct
3 Correct 1 ms 1300 KB Output is correct
4 Correct 28 ms 11448 KB Output is correct
5 Correct 31 ms 14344 KB Output is correct
6 Incorrect 27 ms 13176 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -