답안 #927542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927542 2024-02-15T03:20:37 Z CDuong 길고양이 (JOI20_stray) C++17
85 / 100
37 ms 15260 KB
#include "Anthony.h"
#include<bits/stdc++.h>

using namespace std;

namespace {

int chain[] = {0, 1, 0, 0, 1, 1};

}

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
    vector<vector<int>> G(N);
    for (int i = 0; i < M; ++i) {
        G[U[i]].emplace_back(V[i]);
        G[V[i]].emplace_back(U[i]);
    }

    vector<int> dis(N, INT_MAX), color(N);
    queue<int> q;
    dis[0] = 0; q.emplace(0);
    while (not q.empty()) {
        int u = q.front(); q.pop();
        for (int v : G[u]) if (dis[v] > dis[u] + 1) {
            if (A == 2) {
                if (u == 0) color[v] = 0;
                else if ((int)G[u].size() >= 3) color[v] = !chain[color[u]];
                else color[v] = (color[u] + 1) % 6;
            }
            dis[v] = dis[u] + 1;
            q.emplace(v);
        }
    }

    vector<int> res(M);
    for (int i = 0; i < M; ++i) {
        int u, v;
        tie(u, v) = tie(U[i], V[i]);
        if (dis[u] > dis[v]) swap(u, v);
        if (A == 2) res[i] = chain[color[v]];
        else res[i] = dis[u] % 3;
    }

    // for (int val : res) cout << val << " ";
    // cout << endl;

    return res;
}
#include "Catherine.h"
#include<bits/stdc++.h>

using namespace std;

namespace {

int A, B;
int last = -1;
bool flag = false;
vector<int> vec;
vector<int> chain = {0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1};

}  // namespace

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

int Move(vector<int> cnt) {
	if (A != 2) {
		if (last != -1) ++cnt[last];
		// for (int val : cnt) cout << val << " ";
		// cout << endl;
		if (cnt[0] == 0) return last = 1;
		if (cnt[1] == 0) return last = 2;
		if (cnt[2] == 0) return last = 0;
	}

	int deg = (last != -1);
	for (int i = 0; i < 2; ++i) deg += cnt[i];
	if (deg == 2) {
		if (flag) {
			for (int i = 0; i < 2; ++i) if (cnt[i] == 1) return last = i;
		}
		for (int i = 0; i < 2; ++i) {
			for (int _ = 0; _ < cnt[i]; ++_) vec.emplace_back(i);
		}
		if ((int)vec.size() == 5) {
			flag = true;
			bool way = false;
			for (int i = 0; i <= (int)chain.size() - (int)vec.size(); ++i) {
				int ccnt = 0;
				for (int j = 0; j < (int)vec.size(); ++j) ccnt += vec[j] == chain[i + j];
				way |= ccnt == (int)vec.size();
			}
			if (way) return -1;
			for (int i = 0; i < 2; ++i) if (cnt[i] == 1) return last = i;
		}
		else return last = vec.back();
	}
	else {
		flag = true;
		if (last != -1) ++cnt[last];
		for (int i = 0; i < 2; ++i) if (cnt[i] == 1) {
			if (last == i) return -1;
			else return last = i;
		}
	}
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15260 KB Output is correct
2 Incorrect 0 ms 784 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15260 KB Output is correct
2 Incorrect 0 ms 784 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 12720 KB Output is correct
2 Incorrect 0 ms 796 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 12720 KB Output is correct
2 Incorrect 0 ms 796 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1052 KB Output is correct
2 Correct 0 ms 780 KB Output is correct
3 Correct 1 ms 1044 KB Output is correct
4 Correct 2 ms 1056 KB Output is correct
5 Correct 2 ms 1040 KB Output is correct
6 Correct 2 ms 1048 KB Output is correct
7 Correct 2 ms 1056 KB Output is correct
8 Correct 2 ms 1056 KB Output is correct
9 Correct 1 ms 1048 KB Output is correct
10 Correct 1 ms 1040 KB Output is correct
11 Correct 1 ms 1056 KB Output is correct
12 Correct 2 ms 1044 KB Output is correct
13 Correct 1 ms 1048 KB Output is correct
14 Correct 1 ms 1052 KB Output is correct
15 Correct 2 ms 1048 KB Output is correct
16 Correct 1 ms 1048 KB Output is correct
17 Correct 1 ms 1040 KB Output is correct
18 Correct 2 ms 1048 KB Output is correct
19 Correct 1 ms 1056 KB Output is correct
20 Correct 1 ms 1044 KB Output is correct
21 Correct 1 ms 1056 KB Output is correct
22 Correct 2 ms 1052 KB Output is correct
23 Correct 1 ms 1048 KB Output is correct
24 Correct 2 ms 1052 KB Output is correct
25 Correct 2 ms 1048 KB Output is correct
26 Correct 1 ms 1048 KB Output is correct
27 Correct 1 ms 1552 KB Output is correct
28 Correct 1 ms 1048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 11120 KB Output is correct
2 Correct 27 ms 11792 KB Output is correct
3 Correct 0 ms 796 KB Output is correct
4 Correct 20 ms 11216 KB Output is correct
5 Correct 33 ms 12676 KB Output is correct
6 Correct 28 ms 12676 KB Output is correct
7 Correct 25 ms 11652 KB Output is correct
8 Correct 26 ms 11640 KB Output is correct
9 Correct 31 ms 12668 KB Output is correct
10 Correct 28 ms 12624 KB Output is correct
11 Correct 37 ms 12580 KB Output is correct
12 Correct 33 ms 12608 KB Output is correct
13 Correct 28 ms 12668 KB Output is correct
14 Correct 28 ms 12680 KB Output is correct
15 Correct 32 ms 12684 KB Output is correct
16 Correct 28 ms 12576 KB Output is correct
17 Correct 31 ms 12420 KB Output is correct
18 Correct 27 ms 12268 KB Output is correct
19 Correct 28 ms 12400 KB Output is correct
20 Correct 28 ms 12408 KB Output is correct
21 Correct 31 ms 12420 KB Output is correct
22 Correct 27 ms 12544 KB Output is correct
23 Correct 24 ms 11384 KB Output is correct
24 Correct 25 ms 11544 KB Output is correct
25 Correct 26 ms 11656 KB Output is correct
26 Correct 24 ms 11464 KB Output is correct
27 Correct 27 ms 11808 KB Output is correct
28 Correct 28 ms 11904 KB Output is correct
29 Correct 31 ms 11916 KB Output is correct
30 Correct 27 ms 12116 KB Output is correct
31 Correct 28 ms 11372 KB Output is correct
32 Correct 27 ms 11296 KB Output is correct
33 Correct 24 ms 11564 KB Output is correct
34 Correct 28 ms 11656 KB Output is correct
35 Correct 27 ms 11900 KB Output is correct
36 Correct 26 ms 11876 KB Output is correct
37 Correct 26 ms 11812 KB Output is correct
38 Correct 27 ms 11976 KB Output is correct
39 Correct 27 ms 11896 KB Output is correct
40 Correct 28 ms 11816 KB Output is correct
41 Correct 26 ms 12160 KB Output is correct
42 Correct 30 ms 12060 KB Output is correct
43 Correct 27 ms 12156 KB Output is correct
44 Correct 28 ms 12172 KB Output is correct
45 Correct 30 ms 12152 KB Output is correct
46 Correct 28 ms 12060 KB Output is correct
47 Correct 26 ms 11900 KB Output is correct
48 Correct 27 ms 11884 KB Output is correct
49 Correct 26 ms 11636 KB Output is correct
50 Correct 31 ms 11904 KB Output is correct
51 Correct 25 ms 11648 KB Output is correct
52 Correct 24 ms 11652 KB Output is correct
53 Correct 24 ms 11644 KB Output is correct
54 Correct 26 ms 11656 KB Output is correct
55 Correct 28 ms 11640 KB Output is correct
56 Correct 25 ms 11724 KB Output is correct
57 Correct 25 ms 11652 KB Output is correct
58 Correct 25 ms 11704 KB Output is correct
59 Correct 25 ms 11644 KB Output is correct
60 Correct 25 ms 11616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 11428 KB Output is correct
2 Correct 27 ms 11644 KB Output is correct
3 Correct 0 ms 796 KB Output is correct
4 Correct 20 ms 11320 KB Output is correct
5 Correct 30 ms 12676 KB Output is correct
6 Correct 32 ms 12544 KB Output is correct
7 Correct 25 ms 11656 KB Output is correct
8 Correct 31 ms 11944 KB Output is correct
9 Correct 28 ms 12580 KB Output is correct
10 Correct 28 ms 12676 KB Output is correct
11 Correct 31 ms 12592 KB Output is correct
12 Correct 31 ms 12616 KB Output is correct
13 Correct 37 ms 12584 KB Output is correct
14 Correct 31 ms 12744 KB Output is correct
15 Correct 31 ms 12608 KB Output is correct
16 Correct 31 ms 12664 KB Output is correct
17 Correct 26 ms 12392 KB Output is correct
18 Correct 26 ms 12348 KB Output is correct
19 Correct 27 ms 12360 KB Output is correct
20 Correct 27 ms 12340 KB Output is correct
21 Correct 27 ms 12372 KB Output is correct
22 Correct 31 ms 12324 KB Output is correct
23 Correct 24 ms 11364 KB Output is correct
24 Correct 24 ms 11368 KB Output is correct
25 Correct 26 ms 11636 KB Output is correct
26 Correct 31 ms 11688 KB Output is correct
27 Correct 26 ms 11896 KB Output is correct
28 Correct 31 ms 11892 KB Output is correct
29 Correct 28 ms 11900 KB Output is correct
30 Correct 26 ms 11908 KB Output is correct
31 Correct 26 ms 11312 KB Output is correct
32 Correct 26 ms 11304 KB Output is correct
33 Correct 26 ms 11644 KB Output is correct
34 Correct 26 ms 11524 KB Output is correct
35 Correct 30 ms 11828 KB Output is correct
36 Correct 26 ms 11868 KB Output is correct
37 Correct 28 ms 11808 KB Output is correct
38 Correct 33 ms 11744 KB Output is correct
39 Correct 26 ms 11900 KB Output is correct
40 Correct 26 ms 11900 KB Output is correct
41 Correct 26 ms 12148 KB Output is correct
42 Correct 33 ms 12228 KB Output is correct
43 Correct 27 ms 12168 KB Output is correct
44 Correct 28 ms 12156 KB Output is correct
45 Correct 30 ms 12232 KB Output is correct
46 Correct 28 ms 12080 KB Output is correct
47 Correct 27 ms 11884 KB Output is correct
48 Correct 31 ms 11912 KB Output is correct
49 Correct 28 ms 11792 KB Output is correct
50 Correct 26 ms 11916 KB Output is correct
51 Correct 24 ms 11556 KB Output is correct
52 Correct 26 ms 11656 KB Output is correct
53 Correct 26 ms 11648 KB Output is correct
54 Correct 25 ms 11640 KB Output is correct
55 Correct 25 ms 11648 KB Output is correct
56 Correct 26 ms 11656 KB Output is correct
57 Correct 24 ms 11612 KB Output is correct
58 Correct 26 ms 11664 KB Output is correct
59 Correct 25 ms 11612 KB Output is correct
60 Correct 24 ms 11636 KB Output is correct