답안 #925463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925463 2024-02-11T16:51:39 Z adaawf 길고양이 (JOI20_stray) C++14
100 / 100
37 ms 16760 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[20005];
int f[20005], dx[] = {1, 0, 1, 0, 0, 1}, dd[20005];
vector<int> res;
void dfs(int x, int p) {
    int c = 0;
    for (auto w : g[x]) {
        if (w.second == p) continue;
        c++;
    }
    if (c == 1) {
        for (auto w : g[x]) {
            if (w.second == p) continue;
            res[w.second] = dx[f[x]];
            f[w.first] = (f[x] + 1) % 6;
            dfs(w.first, w.second);
        }
    }
    else {
        for (auto w : g[x]) {
            if (w.second == p) continue;
            if (p == -1) res[w.second] = 0;
            else res[w.second] = res[p] ^ 1;
            if (res[w.second] == 1) f[w.first] = 1;
            else f[w.first] = 2;
            dfs(w.first, w.second);
        }
    }
}
void bfs() {
    queue<int> q;
    q.push(0);
    memset(dd, 0, sizeof dd);
    dd[0] = 1;
    int d = 0;
    while (!q.empty()) {
        int h = q.size();
        for (int i = 0; i < h; i++) {
            int p = q.front();
            q.pop();
            f[p] = d;
            for (auto w : g[p]) {
                if (dd[w.first] == 0) {
                    dd[w.first] = 1;
                    q.push(w.first);
                }
            }
        }
        d++;
    }
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
	res.resize(M);
	for (int i = 0; i < M; i++) {
		g[U[i]].push_back({V[i], i});
		g[V[i]].push_back({U[i], i});
	}
	if (A == 2) {
		for (int i = 0; i < N; i++) f[i] = 0;
		dfs(0, -1);
	}
	else {
		bfs();
		for (int i = 0; i < M; i++) {
			res[i] = min(f[U[i]], f[V[i]]) % 3;
		}
	}
	return res;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
    int A, B, s = 1, flag = 0, k = 0, c = 0, dd[35];
    vector<int> v(5, 0);
}
void Init(int a, int b) {
    A = a;
    B = b;
}
int Move(vector<int> y) {
    dd[5] = dd[18] = dd[25] = dd[12] = dd[22] = dd[11] = 1;
  	if (A == 2) {
		if (s != 0) {
			s = 0;
			if (y[0] + y[1] != 2) {
				if (min(y[0], y[1]) == 0) {
                    if (y[0] < y[1]) k = 1;
                    else k = 0;
				}
				else {
                    if (y[0] > y[1]) k = 1;
                    else k = 0;
				}
				return k;
			}
			else {
				flag = 1;
                if (y[0] < y[1]) k = 1;
                else k = 0;
				y[k]--;
                if (y[0] < y[1]) v[c++] = 1;
                else v[c++] = 0;
				v[c++] = k;
				return k;
			}
		}
		else {
			if (flag == 0) {
				if (min(y[0], y[1]) == 0) {
                    if (y[0] < y[1]) k = 1;
                    else k = 0;
				}
				else k ^= 1;
				return k;
			}
			else {
				if (y[0] + y[1] != 1) {
					flag = c = 0;
					if (min(y[0], y[1]) == 0) return -1;
                    k ^= 1;
                    return k;
				}
                if (y[0] < y[1]) k = 1;
                else k = 0;
                v[c++] = k;
                if (c == 5) {
                    flag = 0;
                    int d = 0;
                    for (int i = 0; i < 5; i++) d += v[i] * (1 << i);
                    if (dd[d] == 0) {
                        return k;
                    }
                    k = v[3];
                    return -1;
                }
                return k;
			}
		}
  	}
	else {
		vector<int> v;
		for (int i = 0; i < 3; i++) {
            if (y[i] != 0) {
                v.push_back(i);
            }
		}
		if (v.size() == 1) {
            return v[0];
		}
        if (v[0] == 0) {
            if (v[1] == 1) return 0;
            return 2;
        }
        return 1;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15736 KB Output is correct
2 Correct 0 ms 1292 KB Output is correct
3 Correct 23 ms 15236 KB Output is correct
4 Correct 34 ms 16760 KB Output is correct
5 Correct 34 ms 16756 KB Output is correct
6 Correct 27 ms 15796 KB Output is correct
7 Correct 27 ms 15400 KB Output is correct
8 Correct 32 ms 16248 KB Output is correct
9 Correct 33 ms 16056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15736 KB Output is correct
2 Correct 0 ms 1292 KB Output is correct
3 Correct 23 ms 15236 KB Output is correct
4 Correct 34 ms 16760 KB Output is correct
5 Correct 34 ms 16756 KB Output is correct
6 Correct 27 ms 15796 KB Output is correct
7 Correct 27 ms 15400 KB Output is correct
8 Correct 32 ms 16248 KB Output is correct
9 Correct 33 ms 16056 KB Output is correct
10 Correct 26 ms 13672 KB Output is correct
11 Correct 26 ms 13912 KB Output is correct
12 Correct 27 ms 13904 KB Output is correct
13 Correct 26 ms 13492 KB Output is correct
14 Correct 26 ms 13948 KB Output is correct
15 Correct 27 ms 14192 KB Output is correct
16 Correct 29 ms 16260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 13180 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 22 ms 12852 KB Output is correct
4 Correct 35 ms 15168 KB Output is correct
5 Correct 34 ms 14640 KB Output is correct
6 Correct 26 ms 13168 KB Output is correct
7 Correct 26 ms 13172 KB Output is correct
8 Correct 30 ms 13952 KB Output is correct
9 Correct 37 ms 14204 KB Output is correct
10 Correct 27 ms 13680 KB Output is correct
11 Correct 27 ms 13688 KB Output is correct
12 Correct 28 ms 13720 KB Output is correct
13 Correct 27 ms 13692 KB Output is correct
14 Correct 30 ms 13944 KB Output is correct
15 Correct 31 ms 13912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 13180 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 22 ms 12852 KB Output is correct
4 Correct 35 ms 15168 KB Output is correct
5 Correct 34 ms 14640 KB Output is correct
6 Correct 26 ms 13168 KB Output is correct
7 Correct 26 ms 13172 KB Output is correct
8 Correct 30 ms 13952 KB Output is correct
9 Correct 37 ms 14204 KB Output is correct
10 Correct 27 ms 13680 KB Output is correct
11 Correct 27 ms 13688 KB Output is correct
12 Correct 28 ms 13720 KB Output is correct
13 Correct 27 ms 13692 KB Output is correct
14 Correct 30 ms 13944 KB Output is correct
15 Correct 31 ms 13912 KB Output is correct
16 Correct 23 ms 11732 KB Output is correct
17 Correct 23 ms 11636 KB Output is correct
18 Correct 24 ms 11640 KB Output is correct
19 Correct 24 ms 11640 KB Output is correct
20 Correct 27 ms 12652 KB Output is correct
21 Correct 26 ms 12020 KB Output is correct
22 Correct 27 ms 14020 KB Output is correct
23 Correct 25 ms 11892 KB Output is correct
24 Correct 25 ms 11900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1560 KB Output is correct
2 Correct 0 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 1564 KB Output is correct
6 Correct 2 ms 1556 KB Output is correct
7 Correct 2 ms 1560 KB Output is correct
8 Correct 2 ms 1564 KB Output is correct
9 Correct 2 ms 1560 KB Output is correct
10 Correct 2 ms 1564 KB Output is correct
11 Correct 2 ms 1564 KB Output is correct
12 Correct 2 ms 1560 KB Output is correct
13 Correct 2 ms 1568 KB Output is correct
14 Correct 1 ms 1568 KB Output is correct
15 Correct 2 ms 1568 KB Output is correct
16 Correct 1 ms 1564 KB Output is correct
17 Correct 2 ms 1564 KB Output is correct
18 Correct 2 ms 1572 KB Output is correct
19 Correct 2 ms 1572 KB Output is correct
20 Correct 2 ms 1572 KB Output is correct
21 Correct 2 ms 1572 KB Output is correct
22 Correct 2 ms 1556 KB Output is correct
23 Correct 1 ms 1572 KB Output is correct
24 Correct 1 ms 1564 KB Output is correct
25 Correct 2 ms 1572 KB Output is correct
26 Correct 2 ms 1572 KB Output is correct
27 Correct 1 ms 1556 KB Output is correct
28 Correct 1 ms 1572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 11488 KB Output is correct
2 Correct 26 ms 13036 KB Output is correct
3 Correct 0 ms 1296 KB Output is correct
4 Correct 20 ms 11572 KB Output is correct
5 Correct 31 ms 14268 KB Output is correct
6 Correct 31 ms 14168 KB Output is correct
7 Correct 26 ms 13144 KB Output is correct
8 Correct 27 ms 13140 KB Output is correct
9 Correct 30 ms 14040 KB Output is correct
10 Correct 30 ms 14168 KB Output is correct
11 Correct 30 ms 14172 KB Output is correct
12 Correct 30 ms 14100 KB Output is correct
13 Correct 32 ms 14168 KB Output is correct
14 Correct 30 ms 14168 KB Output is correct
15 Correct 30 ms 14100 KB Output is correct
16 Correct 31 ms 14132 KB Output is correct
17 Correct 27 ms 13912 KB Output is correct
18 Correct 27 ms 13912 KB Output is correct
19 Correct 27 ms 13972 KB Output is correct
20 Correct 28 ms 13840 KB Output is correct
21 Correct 28 ms 13912 KB Output is correct
22 Correct 28 ms 13900 KB Output is correct
23 Correct 24 ms 11932 KB Output is correct
24 Correct 25 ms 11852 KB Output is correct
25 Correct 25 ms 12360 KB Output is correct
26 Correct 25 ms 12368 KB Output is correct
27 Correct 27 ms 13128 KB Output is correct
28 Correct 26 ms 13028 KB Output is correct
29 Correct 27 ms 13136 KB Output is correct
30 Correct 26 ms 13140 KB Output is correct
31 Correct 25 ms 11864 KB Output is correct
32 Correct 24 ms 11856 KB Output is correct
33 Correct 25 ms 12184 KB Output is correct
34 Correct 25 ms 12296 KB Output is correct
35 Correct 26 ms 12872 KB Output is correct
36 Correct 26 ms 13060 KB Output is correct
37 Correct 27 ms 12880 KB Output is correct
38 Correct 26 ms 12984 KB Output is correct
39 Correct 26 ms 12876 KB Output is correct
40 Correct 26 ms 12884 KB Output is correct
41 Correct 27 ms 13324 KB Output is correct
42 Correct 27 ms 13660 KB Output is correct
43 Correct 27 ms 13372 KB Output is correct
44 Correct 31 ms 13416 KB Output is correct
45 Correct 28 ms 13656 KB Output is correct
46 Correct 28 ms 13532 KB Output is correct
47 Correct 26 ms 12836 KB Output is correct
48 Correct 27 ms 12892 KB Output is correct
49 Correct 27 ms 12880 KB Output is correct
50 Correct 26 ms 12872 KB Output is correct
51 Correct 24 ms 12116 KB Output is correct
52 Correct 25 ms 12228 KB Output is correct
53 Correct 26 ms 12164 KB Output is correct
54 Correct 24 ms 12104 KB Output is correct
55 Correct 25 ms 12108 KB Output is correct
56 Correct 24 ms 12108 KB Output is correct
57 Correct 25 ms 12372 KB Output is correct
58 Correct 25 ms 12188 KB Output is correct
59 Correct 25 ms 12116 KB Output is correct
60 Correct 25 ms 12120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 11396 KB Output is correct
2 Correct 26 ms 12872 KB Output is correct
3 Correct 1 ms 1308 KB Output is correct
4 Correct 20 ms 11572 KB Output is correct
5 Correct 30 ms 14156 KB Output is correct
6 Correct 30 ms 14160 KB Output is correct
7 Correct 27 ms 13140 KB Output is correct
8 Correct 26 ms 13140 KB Output is correct
9 Correct 31 ms 14120 KB Output is correct
10 Correct 28 ms 14100 KB Output is correct
11 Correct 30 ms 14088 KB Output is correct
12 Correct 31 ms 14164 KB Output is correct
13 Correct 30 ms 14084 KB Output is correct
14 Correct 28 ms 14164 KB Output is correct
15 Correct 28 ms 14156 KB Output is correct
16 Correct 30 ms 14200 KB Output is correct
17 Correct 28 ms 14028 KB Output is correct
18 Correct 27 ms 13656 KB Output is correct
19 Correct 34 ms 13736 KB Output is correct
20 Correct 27 ms 13788 KB Output is correct
21 Correct 34 ms 14120 KB Output is correct
22 Correct 26 ms 13908 KB Output is correct
23 Correct 24 ms 11852 KB Output is correct
24 Correct 24 ms 11856 KB Output is correct
25 Correct 24 ms 12368 KB Output is correct
26 Correct 25 ms 12276 KB Output is correct
27 Correct 27 ms 13284 KB Output is correct
28 Correct 30 ms 13104 KB Output is correct
29 Correct 26 ms 13076 KB Output is correct
30 Correct 26 ms 13136 KB Output is correct
31 Correct 24 ms 11824 KB Output is correct
32 Correct 25 ms 11856 KB Output is correct
33 Correct 25 ms 12360 KB Output is correct
34 Correct 25 ms 12372 KB Output is correct
35 Correct 26 ms 12876 KB Output is correct
36 Correct 30 ms 12884 KB Output is correct
37 Correct 26 ms 12880 KB Output is correct
38 Correct 30 ms 12852 KB Output is correct
39 Correct 26 ms 12872 KB Output is correct
40 Correct 26 ms 12872 KB Output is correct
41 Correct 28 ms 13380 KB Output is correct
42 Correct 27 ms 13392 KB Output is correct
43 Correct 27 ms 13912 KB Output is correct
44 Correct 28 ms 13652 KB Output is correct
45 Correct 27 ms 13624 KB Output is correct
46 Correct 30 ms 13652 KB Output is correct
47 Correct 26 ms 13336 KB Output is correct
48 Correct 26 ms 12872 KB Output is correct
49 Correct 26 ms 12620 KB Output is correct
50 Correct 26 ms 12852 KB Output is correct
51 Correct 25 ms 12116 KB Output is correct
52 Correct 25 ms 12112 KB Output is correct
53 Correct 24 ms 12188 KB Output is correct
54 Correct 27 ms 12364 KB Output is correct
55 Correct 24 ms 12116 KB Output is correct
56 Correct 25 ms 12068 KB Output is correct
57 Correct 24 ms 12308 KB Output is correct
58 Correct 25 ms 12372 KB Output is correct
59 Correct 25 ms 12108 KB Output is correct
60 Correct 25 ms 12112 KB Output is correct