답안 #212198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
212198 2020-03-22T13:17:34 Z admin 길고양이 (JOI20_stray) C++14
85 / 100
99 ms 16244 KB
#include "Anthony.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pi;

namespace {

	int sub[20005], hv[20005], w[20005], cdepth[20005], rev;
	vector<int> edges;
	vector<pi> AdjList[20005];
	queue<int> q;
	int cnt[12] = {1,0,0,1,0,1,1,0,0,1,0,1};
	void genchain(int x, int p, int eweight){
		//cerr << x << ' ' << p << ' ' << eweight << '\n';
		int c = 0;
		for (auto it : AdjList[x]){
			if (it.first == p) continue;
			c++;
		}
		if (c >= 2){
			if (eweight == 1) cdepth[x] = 1;
			else cdepth[x] = 0;
			for (auto it : AdjList[x]){
				if (it.first == p) continue;
				cdepth[it.first] = cdepth[x] + 1;
				edges[it.second] = cnt[cdepth[x]%12];
				genchain(it.first,x,edges[it.second]);
			}
		}
		else{
			for (auto it : AdjList[x]){
				if (it.first == p) continue;
				cdepth[it.first] = cdepth[x] + 1;
				edges[it.second] = cnt[cdepth[x]%12];
				genchain(it.first,x,edges[it.second]);
			}
			
		}
	}

}  // namespace

vector<int> Mark(int N, int M, int A, int B,vector<int> U,vector<int> V) {
	for (int i = 0; i < N; ++i){
		AdjList[i].clear();
		cdepth[i] = -1;
	}
	edges.resize(M,-1);
	for (int i = 0; i < M; ++i){
		AdjList[U[i]].push_back(pi(V[i],i));
		AdjList[V[i]].push_back(pi(U[i],i));
	}
	cdepth[0] = 0;
	genchain(0,-1,0);
	for (auto it : edges){
		//cerr << it << ' ';
	}
	//cerr << '\n';
	return edges;
}
#include "Catherine.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pi;

namespace {
	int stage = 0;
	int cnt[12] = {1,0,0,1,0,1,1,0,0,1,0,1};
	int br[12][5];
	vector<int> last;
}  // namespace

void Init(int A, int B) {
	last.clear();
	stage = 0;
	for (int i = 0; i < 12; ++i){
		for (int j = 0; j < 5; ++j){
			br[i][j] = cnt[(i+j)%12];
		}
	}
}

int Move(std::vector<int> y) {
	/*
	cerr << stage << '\n';
	for (auto it : last){
		cerr << it << ' ';
	}
	cerr << '\n';
	*/
	int mv = -1;
	if (stage == 0){
		if (y[0] + y[1] == 1){
			stage = 2;
			if (y[0]){
				last.push_back(0);
				return 0;
			} 
			else{
				last.push_back(1);
				return 1;
			}
		}
		else if (y[0] + y[1] > 2){
			stage = 2;
			if (y[0] == 1) mv = 0;
			else mv = 1;
			last.push_back(mv);
			return mv;
		}
		stage = 1;
		if (y[0] == 2){
			last.push_back(0);
			last.push_back(0);
			return 0;
		}
		else if (y[1] == 2){
			last.push_back(1);
			last.push_back(1);
			return 1;
		}
		else{
			if (y[0] != 0) mv = 0;
			else mv = 1;
			last.push_back(1-mv);
			last.push_back(mv);
			return mv;
		}
		
	}
	else if (stage == 1){
		if (y[0] + y[1] == 1){
			if (last.size() >= 4){
				int checkers[12];
				for (int i = 0; i < 12; ++i) checkers[i] = 1;
				last.push_back((y[0] == 1 ? 0 : 1));
				for (int i = 0; i < 5; ++i){
					for (int j = 0; j < 12; ++j){
						if (last[i] != br[j][i]) checkers[j] = 0;
					}
				}
				last.pop_back();
				for (int i = 0; i < 12; ++i){
					if (checkers[i]){
						stage = 2;
						last.push_back(last.back());
						return -1;
					}
					
				}
			}
		}
		if (y[0] == 0 && y[1] == 0){
			stage = 2;
			last.push_back(last.back());
			return -1;
		}
		else if (y[0] + y[1] == 1){
			if (y[0] == 1) mv = 0;
			else mv = 1;
			last.push_back(mv);
			return mv;
		}
		else{
			stage = 2;
			if (y[0] == 0){
				last.push_back(last.back());
				return -1;
			}
			else if (y[1] == 0){
				last.push_back(last.back());
				return -1;
			}
			else{
				int x = last.back();
				last.push_back(1-x);
				return 1-x;
			}
		}
		
		
	}
	else{
		if (y[0] + y[1] == 1){
			if (y[1] == 1){
				last.push_back(1);
				return 1;
			} 
			if (y[0] == 1){
				last.push_back(0);
				return 0;
			}
		}
		else{
			int x = last.back();
			last.push_back(1-x);
			return 1-x;
		}
	}
	
	
}
 

Compilation message

Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:57:12: warning: unused variable 'it' [-Wunused-variable]
  for (auto it : edges){
            ^~
Anthony.cpp: At global scope:
Anthony.cpp:10:54: warning: '{anonymous}::rev' defined but not used [-Wunused-variable]
  int sub[20005], hv[20005], w[20005], cdepth[20005], rev;
                                                      ^~~
Anthony.cpp:10:29: warning: '{anonymous}::w' defined but not used [-Wunused-variable]
  int sub[20005], hv[20005], w[20005], cdepth[20005], rev;
                             ^
Anthony.cpp:10:18: warning: '{anonymous}::hv' defined but not used [-Wunused-variable]
  int sub[20005], hv[20005], w[20005], cdepth[20005], rev;
                  ^~
Anthony.cpp:10:6: warning: '{anonymous}::sub' defined but not used [-Wunused-variable]
  int sub[20005], hv[20005], w[20005], cdepth[20005], rev;
      ^~~

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:144:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 16244 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 16244 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 13796 KB Output is correct
2 Correct 11 ms 1720 KB Output is correct
3 Correct 51 ms 13360 KB Output is correct
4 Correct 69 ms 15948 KB Output is correct
5 Incorrect 94 ms 16004 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 13796 KB Output is correct
2 Correct 11 ms 1720 KB Output is correct
3 Correct 51 ms 13360 KB Output is correct
4 Correct 69 ms 15948 KB Output is correct
5 Incorrect 94 ms 16004 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1744 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 11 ms 1536 KB Output is correct
4 Correct 11 ms 1792 KB Output is correct
5 Correct 11 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 10 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 1792 KB Output is correct
12 Correct 10 ms 1792 KB Output is correct
13 Correct 10 ms 1896 KB Output is correct
14 Correct 11 ms 1792 KB Output is correct
15 Correct 10 ms 1792 KB Output is correct
16 Correct 10 ms 1792 KB Output is correct
17 Correct 11 ms 1792 KB Output is correct
18 Correct 10 ms 1792 KB Output is correct
19 Correct 11 ms 1792 KB Output is correct
20 Correct 10 ms 1536 KB Output is correct
21 Correct 11 ms 1792 KB Output is correct
22 Correct 10 ms 1792 KB Output is correct
23 Correct 10 ms 1792 KB Output is correct
24 Correct 10 ms 1792 KB Output is correct
25 Correct 10 ms 1744 KB Output is correct
26 Correct 11 ms 1792 KB Output is correct
27 Correct 11 ms 1856 KB Output is correct
28 Correct 11 ms 1552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 11924 KB Output is correct
2 Correct 59 ms 12940 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 44 ms 11640 KB Output is correct
5 Correct 99 ms 14396 KB Output is correct
6 Correct 68 ms 14404 KB Output is correct
7 Correct 53 ms 13364 KB Output is correct
8 Correct 70 ms 13376 KB Output is correct
9 Correct 70 ms 13812 KB Output is correct
10 Correct 68 ms 13948 KB Output is correct
11 Correct 75 ms 14412 KB Output is correct
12 Correct 64 ms 14412 KB Output is correct
13 Correct 63 ms 13940 KB Output is correct
14 Correct 79 ms 14124 KB Output is correct
15 Correct 72 ms 13832 KB Output is correct
16 Correct 70 ms 14360 KB Output is correct
17 Correct 72 ms 14044 KB Output is correct
18 Correct 67 ms 13472 KB Output is correct
19 Correct 62 ms 13448 KB Output is correct
20 Correct 64 ms 14072 KB Output is correct
21 Correct 81 ms 14048 KB Output is correct
22 Correct 82 ms 13696 KB Output is correct
23 Correct 63 ms 11476 KB Output is correct
24 Correct 68 ms 11388 KB Output is correct
25 Correct 59 ms 11932 KB Output is correct
26 Correct 54 ms 11900 KB Output is correct
27 Correct 62 ms 12724 KB Output is correct
28 Correct 60 ms 13004 KB Output is correct
29 Correct 65 ms 12928 KB Output is correct
30 Correct 63 ms 12816 KB Output is correct
31 Correct 54 ms 11948 KB Output is correct
32 Correct 51 ms 11516 KB Output is correct
33 Correct 58 ms 11772 KB Output is correct
34 Correct 54 ms 11908 KB Output is correct
35 Correct 80 ms 12644 KB Output is correct
36 Correct 64 ms 12756 KB Output is correct
37 Correct 57 ms 12704 KB Output is correct
38 Correct 63 ms 12776 KB Output is correct
39 Correct 57 ms 13004 KB Output is correct
40 Correct 56 ms 12648 KB Output is correct
41 Correct 62 ms 13276 KB Output is correct
42 Correct 68 ms 13180 KB Output is correct
43 Correct 77 ms 13124 KB Output is correct
44 Correct 70 ms 13044 KB Output is correct
45 Correct 66 ms 13544 KB Output is correct
46 Correct 67 ms 13644 KB Output is correct
47 Correct 70 ms 12532 KB Output is correct
48 Correct 56 ms 12304 KB Output is correct
49 Correct 63 ms 12276 KB Output is correct
50 Correct 56 ms 12716 KB Output is correct
51 Correct 56 ms 11764 KB Output is correct
52 Correct 54 ms 12108 KB Output is correct
53 Correct 52 ms 12180 KB Output is correct
54 Correct 55 ms 12252 KB Output is correct
55 Correct 54 ms 12160 KB Output is correct
56 Correct 52 ms 12248 KB Output is correct
57 Correct 67 ms 12104 KB Output is correct
58 Correct 63 ms 12084 KB Output is correct
59 Correct 69 ms 12164 KB Output is correct
60 Correct 68 ms 12108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 11432 KB Output is correct
2 Correct 57 ms 12620 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 47 ms 11752 KB Output is correct
5 Correct 83 ms 14324 KB Output is correct
6 Correct 84 ms 14556 KB Output is correct
7 Correct 67 ms 13512 KB Output is correct
8 Correct 55 ms 12964 KB Output is correct
9 Correct 69 ms 14420 KB Output is correct
10 Correct 73 ms 14284 KB Output is correct
11 Correct 71 ms 14284 KB Output is correct
12 Correct 78 ms 14404 KB Output is correct
13 Correct 72 ms 14040 KB Output is correct
14 Correct 77 ms 14268 KB Output is correct
15 Correct 71 ms 14396 KB Output is correct
16 Correct 65 ms 13924 KB Output is correct
17 Correct 72 ms 14108 KB Output is correct
18 Correct 65 ms 14044 KB Output is correct
19 Correct 68 ms 13924 KB Output is correct
20 Correct 74 ms 14080 KB Output is correct
21 Correct 64 ms 14028 KB Output is correct
22 Correct 69 ms 13680 KB Output is correct
23 Correct 56 ms 11880 KB Output is correct
24 Correct 52 ms 11372 KB Output is correct
25 Correct 57 ms 12320 KB Output is correct
26 Correct 53 ms 11900 KB Output is correct
27 Correct 59 ms 12788 KB Output is correct
28 Correct 66 ms 13076 KB Output is correct
29 Correct 65 ms 13116 KB Output is correct
30 Correct 60 ms 12796 KB Output is correct
31 Correct 51 ms 11860 KB Output is correct
32 Correct 63 ms 11936 KB Output is correct
33 Correct 53 ms 12356 KB Output is correct
34 Correct 55 ms 11872 KB Output is correct
35 Correct 59 ms 12808 KB Output is correct
36 Correct 68 ms 12404 KB Output is correct
37 Correct 56 ms 12532 KB Output is correct
38 Correct 63 ms 13040 KB Output is correct
39 Correct 67 ms 12876 KB Output is correct
40 Correct 61 ms 12988 KB Output is correct
41 Correct 67 ms 13256 KB Output is correct
42 Correct 69 ms 13180 KB Output is correct
43 Correct 62 ms 13044 KB Output is correct
44 Correct 60 ms 13276 KB Output is correct
45 Correct 76 ms 13268 KB Output is correct
46 Correct 64 ms 13204 KB Output is correct
47 Correct 64 ms 12404 KB Output is correct
48 Correct 69 ms 12268 KB Output is correct
49 Correct 61 ms 12284 KB Output is correct
50 Correct 63 ms 12436 KB Output is correct
51 Correct 57 ms 11776 KB Output is correct
52 Correct 61 ms 11764 KB Output is correct
53 Correct 56 ms 11748 KB Output is correct
54 Correct 53 ms 11644 KB Output is correct
55 Correct 53 ms 11760 KB Output is correct
56 Correct 60 ms 11792 KB Output is correct
57 Correct 61 ms 11508 KB Output is correct
58 Correct 55 ms 11636 KB Output is correct
59 Correct 56 ms 11784 KB Output is correct
60 Correct 51 ms 12032 KB Output is correct