답안 #223873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223873 2020-04-16T19:20:11 Z super_j6 길고양이 (JOI20_stray) C++14
85 / 100
75 ms 14732 KB
//#include "Anthony.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define vi vector<int>

const int maxn = 20000, k = 6;
int d[maxn];
vi graph[maxn];
queue<int> q;
int s[k] = {0, 0, 1, 0, 1, 1};
vi ans;

vi Mark(int n, int m, int a, int b, vi u, vi v){
	ans.resize(m);
	for(int i = 0; i < m; i++){
		graph[u[i]].push_back(i);
		graph[v[i]].push_back(i);
	}
	d[0] = 1;
	if(a > 2){
		q.push(0);
		while(!q.empty()){
			int c = q.front();
			q.pop();
			for(int i : graph[c]){
				int j = u[i] ^ v[i] ^ c; 
				if(d[j]){
					d[j] = d[c] + 1;
					q.push(j);
				}
				if(d[j] == d[c] || d[j] == d[c] + 1){
					ans[i] = d[c] % 3;
				}
			}
		}
	}else{
		function<void(int, int)> dfs = [&](int c, int p){
			for(int i : graph[c]){
				int j = u[i] ^ v[i] ^ c;
				if(j != p){
					ans[i] = s[d[c]];
					d[j] = graph[j].size() > 2 ? (ans[i] ^ 1) << 1 : (d[c] + 1) % k;
					dfs(j, c);
				}
			}
		};
		dfs(0, -1);
	}
	return ans;
}
#include "Catherine.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second
#define vi vector<int>

const int k = 6;
int a, b;
int prv = -1;
bool f = 0;
int s[k] = {0, 0, 1, 0, 1, 1};
vi t;

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

int Move(vi v){
	if(a > 2){
		if(~prv) v[prv]++;
		for(int i = 0; i < 3; i++){
			if(v[i] && v[(i + 1) % 3]) return prv = i;
		}
		for(int i = 0; i < 3; i++){
			if(v[i]) return prv = i;
		}
	}else{
		if(f){
			if(v[0] + v[1] > 1) v[prv]++;
			return prv = (v[0] == 1) ^ 1;
		}
		if(!~prv){
			if(v[0] + v[1] != 2){
				f = 1;
				return prv = (v[0] == 1) ^ 1; 
			}
			prv = (v[0] > 0) ^ 1;
			t.push_back((v[0] > 1) ^ 1);
			t.push_back(prv);
			return prv;
		}
		if(v[0] + v[1] == 0){
			f = 1;
			return -1;
		}
		if(v[0] + v[1] > 1){
			f = 1;
			return !v[prv] ? -1 : prv ^= 1;
		}
		t.push_back((v[0] == 1) ^ 1);
		if(t.size() == k - 1){
			for(int i = 0; i < k; i++){
				f = 1;
				for(int j = 0; j < k - 1; j++) f &= s[(i + j) % k] == t[j];
				if(f) return -1;
			}
			f = 1;
		}
		return prv = (v[0] == 1) ^ 1;
	}
	return -2;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 14460 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 14460 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 12484 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 12484 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1536 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 10 ms 1792 KB Output is correct
4 Correct 10 ms 1792 KB Output is correct
5 Correct 10 ms 1792 KB Output is correct
6 Correct 10 ms 1792 KB Output is correct
7 Correct 10 ms 1792 KB Output is correct
8 Correct 11 ms 1792 KB Output is correct
9 Correct 10 ms 1792 KB Output is correct
10 Correct 10 ms 1792 KB Output is correct
11 Correct 10 ms 2048 KB Output is correct
12 Correct 10 ms 1792 KB Output is correct
13 Correct 10 ms 1792 KB Output is correct
14 Correct 10 ms 1792 KB Output is correct
15 Correct 10 ms 1792 KB Output is correct
16 Correct 10 ms 1804 KB Output is correct
17 Correct 11 ms 1792 KB Output is correct
18 Correct 10 ms 1792 KB Output is correct
19 Correct 13 ms 1792 KB Output is correct
20 Correct 10 ms 1792 KB Output is correct
21 Correct 10 ms 1536 KB Output is correct
22 Correct 10 ms 1804 KB Output is correct
23 Correct 10 ms 1560 KB Output is correct
24 Correct 10 ms 1536 KB Output is correct
25 Correct 10 ms 1792 KB Output is correct
26 Correct 10 ms 1792 KB Output is correct
27 Correct 10 ms 1792 KB Output is correct
28 Correct 10 ms 1792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 11456 KB Output is correct
2 Correct 52 ms 13044 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 43 ms 11604 KB Output is correct
5 Correct 59 ms 14724 KB Output is correct
6 Correct 59 ms 14724 KB Output is correct
7 Correct 51 ms 13780 KB Output is correct
8 Correct 56 ms 13772 KB Output is correct
9 Correct 59 ms 14540 KB Output is correct
10 Correct 59 ms 14612 KB Output is correct
11 Correct 61 ms 14732 KB Output is correct
12 Correct 62 ms 14628 KB Output is correct
13 Correct 62 ms 14716 KB Output is correct
14 Correct 57 ms 14596 KB Output is correct
15 Correct 62 ms 14728 KB Output is correct
16 Correct 59 ms 14568 KB Output is correct
17 Correct 56 ms 14508 KB Output is correct
18 Correct 59 ms 14320 KB Output is correct
19 Correct 55 ms 14332 KB Output is correct
20 Correct 63 ms 14348 KB Output is correct
21 Correct 56 ms 14348 KB Output is correct
22 Correct 55 ms 14340 KB Output is correct
23 Correct 48 ms 11732 KB Output is correct
24 Correct 49 ms 11776 KB Output is correct
25 Correct 50 ms 12528 KB Output is correct
26 Correct 49 ms 12496 KB Output is correct
27 Correct 56 ms 13192 KB Output is correct
28 Correct 55 ms 13192 KB Output is correct
29 Correct 55 ms 13296 KB Output is correct
30 Correct 57 ms 13296 KB Output is correct
31 Correct 48 ms 11900 KB Output is correct
32 Correct 48 ms 11860 KB Output is correct
33 Correct 48 ms 12348 KB Output is correct
34 Correct 50 ms 12240 KB Output is correct
35 Correct 53 ms 13252 KB Output is correct
36 Correct 53 ms 13016 KB Output is correct
37 Correct 53 ms 13012 KB Output is correct
38 Correct 54 ms 13256 KB Output is correct
39 Correct 53 ms 13004 KB Output is correct
40 Correct 57 ms 13240 KB Output is correct
41 Correct 55 ms 13644 KB Output is correct
42 Correct 57 ms 13652 KB Output is correct
43 Correct 55 ms 13760 KB Output is correct
44 Correct 56 ms 13652 KB Output is correct
45 Correct 59 ms 13660 KB Output is correct
46 Correct 61 ms 13644 KB Output is correct
47 Correct 54 ms 12808 KB Output is correct
48 Correct 54 ms 13100 KB Output is correct
49 Correct 55 ms 12820 KB Output is correct
50 Correct 56 ms 12900 KB Output is correct
51 Correct 50 ms 12164 KB Output is correct
52 Correct 52 ms 11988 KB Output is correct
53 Correct 49 ms 12184 KB Output is correct
54 Correct 57 ms 12184 KB Output is correct
55 Correct 51 ms 12192 KB Output is correct
56 Correct 53 ms 12196 KB Output is correct
57 Correct 51 ms 12172 KB Output is correct
58 Correct 63 ms 12160 KB Output is correct
59 Correct 50 ms 12188 KB Output is correct
60 Correct 54 ms 12196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 11516 KB Output is correct
2 Correct 56 ms 12932 KB Output is correct
3 Correct 11 ms 1536 KB Output is correct
4 Correct 45 ms 11608 KB Output is correct
5 Correct 62 ms 14704 KB Output is correct
6 Correct 69 ms 14668 KB Output is correct
7 Correct 55 ms 13696 KB Output is correct
8 Correct 54 ms 13824 KB Output is correct
9 Correct 61 ms 14580 KB Output is correct
10 Correct 66 ms 14724 KB Output is correct
11 Correct 67 ms 14592 KB Output is correct
12 Correct 63 ms 14676 KB Output is correct
13 Correct 61 ms 14620 KB Output is correct
14 Correct 75 ms 14668 KB Output is correct
15 Correct 75 ms 14700 KB Output is correct
16 Correct 59 ms 14724 KB Output is correct
17 Correct 63 ms 14292 KB Output is correct
18 Correct 60 ms 14352 KB Output is correct
19 Correct 63 ms 14520 KB Output is correct
20 Correct 57 ms 14292 KB Output is correct
21 Correct 56 ms 14348 KB Output is correct
22 Correct 57 ms 14292 KB Output is correct
23 Correct 51 ms 11752 KB Output is correct
24 Correct 51 ms 11784 KB Output is correct
25 Correct 49 ms 12248 KB Output is correct
26 Correct 49 ms 12244 KB Output is correct
27 Correct 56 ms 13168 KB Output is correct
28 Correct 56 ms 13200 KB Output is correct
29 Correct 59 ms 13140 KB Output is correct
30 Correct 55 ms 13400 KB Output is correct
31 Correct 50 ms 11892 KB Output is correct
32 Correct 51 ms 11852 KB Output is correct
33 Correct 49 ms 12488 KB Output is correct
34 Correct 51 ms 12488 KB Output is correct
35 Correct 60 ms 13248 KB Output is correct
36 Correct 55 ms 13012 KB Output is correct
37 Correct 53 ms 13104 KB Output is correct
38 Correct 56 ms 13012 KB Output is correct
39 Correct 54 ms 13012 KB Output is correct
40 Correct 53 ms 13244 KB Output is correct
41 Correct 61 ms 13652 KB Output is correct
42 Correct 55 ms 13656 KB Output is correct
43 Correct 55 ms 13644 KB Output is correct
44 Correct 60 ms 13888 KB Output is correct
45 Correct 59 ms 13656 KB Output is correct
46 Correct 56 ms 13676 KB Output is correct
47 Correct 52 ms 12968 KB Output is correct
48 Correct 55 ms 12916 KB Output is correct
49 Correct 51 ms 12828 KB Output is correct
50 Correct 55 ms 12960 KB Output is correct
51 Correct 49 ms 12188 KB Output is correct
52 Correct 50 ms 12192 KB Output is correct
53 Correct 49 ms 12184 KB Output is correct
54 Correct 54 ms 12228 KB Output is correct
55 Correct 51 ms 12196 KB Output is correct
56 Correct 51 ms 12200 KB Output is correct
57 Correct 52 ms 12204 KB Output is correct
58 Correct 53 ms 11992 KB Output is correct
59 Correct 49 ms 12192 KB Output is correct
60 Correct 53 ms 12196 KB Output is correct