답안 #566007

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566007 2022-05-21T16:22:48 Z InternetPerson10 길고양이 (JOI20_stray) C++17
76 / 100
56 ms 15732 KB
#include "Anthony.h"
#include <bits/stdc++.h>

using namespace std;

#include <vector>

namespace {

    // orig: 1 1 0 1 0 0
vector<int> sixchain = {1, 1, 0, 1, 0, 0};
vector<vector<pair<int, int>>> adj;
vector<int> marks, chain;

struct dsu {
    vector<int> par, siz;
    dsu(int n) {
        par.resize(n);
        siz.resize(n, 1);
        for(int i = 0; i < n; i++) par[i] = i;
    }
    int get(int x) {
        if(par[x] == x) return x;
        return par[x] = get(par[x]);
    }
    bool unite(int x, int y) {
        x = get(x); y = get(y);
        if(x == y) return false;
        if(siz[x] > siz[y]) swap(x, y);
        par[x] = y;
        siz[y] += siz[x];
        return true;
    }
};

void dfs(int n, int par = -1, int na = -1, int ne = -1) {
    if(na != -1) {
        if(adj[par].size() == 2) {
            chain[n] = (chain[par] + 1) % 6;
            if(ne == -1) marks[na] = 0;
            else marks[na] = sixchain[chain[n]];
        }
        else {
            chain[n] = -1;
            if(ne == -1) marks[na] = 0;
            else marks[na] = (1 + marks[ne]) % 2;
        }
    }
    for(auto p : adj[n]) {
        int ch, nu;
        tie(ch, nu) = p;
        if(ch == par) continue;
        dfs(ch, n, nu, na);
    }
}

}  // namespace

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
    marks.resize(M, 0);
    chain.resize(N, 0);
    adj.resize(N);
    if(M != N - 1) {
        dsu uf(N);
        vector<int> v1, v2;
        for(int i = 0; i < M; i++) {
            if(!uf.unite(U[i], V[i])) {
                U[i] = V[i] = -1;
                marks[i] = 2;
            }
        }
    }
    for(int i = 0; i < M; i++) {
        if(U[i] == -1) continue;
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
    }
    dfs(0);
    return marks;
}
#include "Catherine.h"
#include <bits/stdc++.h>

using namespace std;

namespace {

vector<int> sixchain = {1, 1, 0, 1, 0, 0};
vector<vector<pair<int, int>>> adj;
vector<int> marks, chain;

vector<int> marksGot;
int goBack = -1;
int goUp = 0;

set<vector<int>> goingDown = {
    {1, 1, 0, 1, 0, 0},
    {1, 0, 1, 0, 0, 1},
    {0, 1, 0, 0, 1, 1},
    {1, 0, 0, 1, 1, 0},
    {0, 0, 1, 1, 0, 1},
    {0, 1, 1, 0, 1, 0}
};

}  // namespace

void Init(int A, int B) {
}

vector<int> y;

int findVal(int x) {
    marksGot.push_back(x);
    return x;
}

int Move(std::vector<int> k) {
    y = k;
    int ySize = y[0] + y[1], mini = 2;
    if(y[0]) mini = 0;
    else mini = 1;
    if(marksGot.size() == 0) {
        if(ySize == 1) {
            goUp = 1;
            return findVal(mini);
        }
        if(ySize == 2) {
            return findVal(mini);
        }
        goUp = 1;
        if(y[0] == 1) return findVal(0);
        return findVal(1);
    }
    if(goBack > -1) {
        goBack--;
        if(goBack == -1) goUp = 1;
        return findVal(mini);
    }
    if(goUp) {
        if(ySize == 1) {
            return findVal(mini);
        }
        int x = marksGot.back();
        return findVal(1-x);
    }
    if(ySize == 0) { // Reached leaf
        marksGot.push_back(marksGot.back());
        goUp = 1;
        return -1;
    }
    if(ySize == 1 && marksGot.size() < 6) {
        return findVal(mini);
    }
    if(ySize == 1 && marksGot.size() == 6) {
        if(goingDown.count(marksGot)) {
            goBack = 4;
            marksGot.push_back(marksGot[5]);
            return -1;
        }
        else { // Going up na pala
            goUp = 1;
            return findVal(mini);
        }
    }
    if(ySize > 1) {
        goUp = 1;
        if(y[0] == 0) {
            marksGot.push_back(1);
            return -1;
        }
        if(y[1] == 0) {
            marksGot.push_back(0);
            return -1;
        }
        return findVal(1-marksGot.back());
    }
    while(true) {}
    assert(false);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 15732 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 15732 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 13312 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 30 ms 12612 KB Output is correct
4 Correct 40 ms 15032 KB Output is correct
5 Incorrect 41 ms 14932 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 13312 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 30 ms 12612 KB Output is correct
4 Correct 40 ms 15032 KB Output is correct
5 Incorrect 41 ms 14932 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 904 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 1 ms 908 KB Output is correct
4 Correct 2 ms 904 KB Output is correct
5 Correct 2 ms 908 KB Output is correct
6 Correct 2 ms 896 KB Output is correct
7 Correct 2 ms 892 KB Output is correct
8 Correct 2 ms 904 KB Output is correct
9 Correct 2 ms 904 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 2 ms 896 KB Output is correct
13 Correct 2 ms 896 KB Output is correct
14 Correct 2 ms 904 KB Output is correct
15 Correct 1 ms 900 KB Output is correct
16 Correct 2 ms 900 KB Output is correct
17 Correct 2 ms 896 KB Output is correct
18 Correct 2 ms 904 KB Output is correct
19 Correct 2 ms 900 KB Output is correct
20 Correct 2 ms 904 KB Output is correct
21 Correct 2 ms 904 KB Output is correct
22 Correct 2 ms 892 KB Output is correct
23 Correct 2 ms 896 KB Output is correct
24 Correct 2 ms 904 KB Output is correct
25 Correct 2 ms 896 KB Output is correct
26 Correct 2 ms 896 KB Output is correct
27 Correct 2 ms 904 KB Output is correct
28 Correct 2 ms 908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 11460 KB Output is correct
2 Correct 34 ms 12156 KB Output is correct
3 Correct 0 ms 516 KB Output is correct
4 Correct 27 ms 11140 KB Output is correct
5 Correct 47 ms 13480 KB Output is correct
6 Correct 52 ms 13276 KB Output is correct
7 Correct 33 ms 12368 KB Output is correct
8 Correct 32 ms 12392 KB Output is correct
9 Correct 40 ms 13228 KB Output is correct
10 Correct 38 ms 13312 KB Output is correct
11 Correct 40 ms 13312 KB Output is correct
12 Correct 40 ms 13420 KB Output is correct
13 Correct 39 ms 13420 KB Output is correct
14 Correct 56 ms 13328 KB Output is correct
15 Correct 40 ms 13344 KB Output is correct
16 Correct 41 ms 13384 KB Output is correct
17 Correct 39 ms 13072 KB Output is correct
18 Correct 40 ms 13176 KB Output is correct
19 Correct 37 ms 13052 KB Output is correct
20 Correct 36 ms 13036 KB Output is correct
21 Correct 35 ms 13092 KB Output is correct
22 Correct 35 ms 12960 KB Output is correct
23 Correct 32 ms 11344 KB Output is correct
24 Correct 33 ms 11228 KB Output is correct
25 Correct 31 ms 11496 KB Output is correct
26 Correct 31 ms 11444 KB Output is correct
27 Correct 35 ms 12296 KB Output is correct
28 Correct 35 ms 12232 KB Output is correct
29 Correct 34 ms 12176 KB Output is correct
30 Correct 35 ms 12232 KB Output is correct
31 Correct 31 ms 11236 KB Output is correct
32 Correct 32 ms 11236 KB Output is correct
33 Correct 31 ms 11624 KB Output is correct
34 Correct 31 ms 11440 KB Output is correct
35 Correct 35 ms 12188 KB Output is correct
36 Correct 35 ms 12092 KB Output is correct
37 Correct 36 ms 12060 KB Output is correct
38 Correct 35 ms 12204 KB Output is correct
39 Correct 36 ms 12052 KB Output is correct
40 Correct 35 ms 12132 KB Output is correct
41 Correct 38 ms 12636 KB Output is correct
42 Correct 38 ms 12820 KB Output is correct
43 Correct 36 ms 12736 KB Output is correct
44 Correct 36 ms 12648 KB Output is correct
45 Correct 37 ms 12688 KB Output is correct
46 Correct 37 ms 12656 KB Output is correct
47 Correct 34 ms 12044 KB Output is correct
48 Correct 34 ms 12016 KB Output is correct
49 Correct 37 ms 11968 KB Output is correct
50 Correct 35 ms 12212 KB Output is correct
51 Correct 32 ms 11428 KB Output is correct
52 Correct 34 ms 11492 KB Output is correct
53 Correct 32 ms 11548 KB Output is correct
54 Correct 33 ms 11448 KB Output is correct
55 Correct 33 ms 11476 KB Output is correct
56 Correct 33 ms 11472 KB Output is correct
57 Correct 32 ms 11248 KB Output is correct
58 Correct 35 ms 11156 KB Output is correct
59 Correct 31 ms 11476 KB Output is correct
60 Correct 35 ms 11576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 11308 KB Output is correct
2 Correct 35 ms 11912 KB Output is correct
3 Correct 1 ms 516 KB Output is correct
4 Correct 27 ms 11116 KB Output is correct
5 Correct 40 ms 13456 KB Output is correct
6 Correct 41 ms 13460 KB Output is correct
7 Incorrect 30 ms 12420 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -