답안 #246347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246347 2020-07-08T18:37:01 Z kostia244 길고양이 (JOI20_stray) C++17
85 / 100
77 ms 21340 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;


namespace anton {
const int maxn = 1<<17;
vector<int> val, p, pidx, col,  god = {0, 0, 1, 0, 1, 1};
vector<array<int, 2>> g[maxn];
void dfs(int v) {
	for(auto &[i, idx] : g[v]) if(i != p[v]) {
		p[i] = v, pidx[i] = idx;
		col[i] = col[v]^1;
		dfs(i);
	}
	//cout << v << " // " << col[v] << '\n';
	if(!v || g[v].size() == 2) return;
	int u = p[v];
	vector<int> l {v};
	while(u && g[u].size() == 2) {
		l.pb(u);
		u = p[u];
	}
	int b = 0;
	while(god[b] != col[v] || god[(b + l.size() - 1)%6] != col[l.back()]) b++;
	//cout << v << " /// " << b << endl;
	//cout << god[b] << " vs " << col[v] << '\n';
	for(int i = 0; i < l.size(); i++) val[pidx[l[i]]] = god[(i+b)%6];
}

} 

std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
  using namespace anton;
  val.resize(M);
  for(int i = 0; i < M; i++) {
	  g[U[i]].pb({V[i], i});
	  g[V[i]].pb({U[i], i});
  }
  p.resize(N);
  pidx.resize(N);
  col.resize(N);
  dfs(0);
  //for(int i = 0; i < M; i++) cout << U[i] << " " << V[i] << " " << val[i] << '\n';
  return val;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

namespace kate {

int A, B, gg = 0, lst = -2, mvs = 0;
string cur, god = "110100110100";
int decide(vector<int> c) {
	if(mvs++ > 10 && !gg) exit(-1);
	if(c[0] + c[1] == 0) {
		gg = 1;
		return -1;
	}
	if(lst == -2 && c[0]+c[1] == 1) {
		gg = 1;
		return lst = c[1];
	}
	if(c[0] + c[1] + (lst != -2) > 2) {
		gg = 1;
		if(c[0] == 0) return -1;
		if(c[1] == 0) return -1;
		if(c[0] == 1 && lst != 0) return lst = 0;
		if(c[1] == 1 && lst != 1) return lst = 1;
		exit(-1);
	}
	if(c[0] + c[1] == 2) {
		if(c[0]) {
			cur.pb('0'+c[1]);
			cur.pb('0');
			return lst = 0;
		}
		cur += "11";
		return lst = 1;
	}
	if(gg) return lst = c[1];
	cur.pb('0'+c[1]);
	if(cur.size() == 5) {
		gg = 1;
		//cout << " " << gg << "Yay\n";
		if(god.find(cur) != string::npos) return -1;
	}
	return lst = c[1];
}


}  // namespace

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

int Move(std::vector<int> y) {
	//cout << y[0] << " " << y[1] << " go ";
	int t = kate::decide(y);
	//cout <<kate::cur << " " << t << endl;
	return t;
}

Compilation message

Anthony.cpp: In function 'void anton::dfs(int)':
Anthony.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < l.size(); i++) val[pidx[l[i]]] = god[(i+b)%6];
                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 19560 KB Output is correct
2 Correct 10 ms 6912 KB Output is correct
3 Correct 49 ms 18328 KB Output is correct
4 Correct 75 ms 21180 KB Output is correct
5 Correct 73 ms 21340 KB Output is correct
6 Incorrect 55 ms 18904 KB Wrong Answer [6]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 19560 KB Output is correct
2 Correct 10 ms 6912 KB Output is correct
3 Correct 49 ms 18328 KB Output is correct
4 Correct 75 ms 21180 KB Output is correct
5 Correct 73 ms 21340 KB Output is correct
6 Incorrect 55 ms 18904 KB Wrong Answer [6]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 16964 KB Output is correct
2 Correct 12 ms 6656 KB Output is correct
3 Correct 65 ms 16000 KB Output is correct
4 Correct 67 ms 19068 KB Output is correct
5 Correct 67 ms 19008 KB Output is correct
6 Incorrect 53 ms 16912 KB Wrong Answer [6]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 16964 KB Output is correct
2 Correct 12 ms 6656 KB Output is correct
3 Correct 65 ms 16000 KB Output is correct
4 Correct 67 ms 19068 KB Output is correct
5 Correct 67 ms 19008 KB Output is correct
6 Incorrect 53 ms 16912 KB Wrong Answer [6]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 6912 KB Output is correct
2 Correct 10 ms 6864 KB Output is correct
3 Correct 11 ms 6912 KB Output is correct
4 Correct 11 ms 6912 KB Output is correct
5 Correct 12 ms 6912 KB Output is correct
6 Correct 11 ms 6912 KB Output is correct
7 Correct 13 ms 6912 KB Output is correct
8 Correct 12 ms 6912 KB Output is correct
9 Correct 11 ms 6912 KB Output is correct
10 Correct 11 ms 6912 KB Output is correct
11 Correct 11 ms 6912 KB Output is correct
12 Correct 12 ms 6912 KB Output is correct
13 Correct 14 ms 6912 KB Output is correct
14 Correct 12 ms 6912 KB Output is correct
15 Correct 14 ms 6912 KB Output is correct
16 Correct 13 ms 6912 KB Output is correct
17 Correct 12 ms 6912 KB Output is correct
18 Correct 13 ms 6912 KB Output is correct
19 Correct 13 ms 6912 KB Output is correct
20 Correct 12 ms 7168 KB Output is correct
21 Correct 12 ms 6912 KB Output is correct
22 Correct 12 ms 6912 KB Output is correct
23 Correct 12 ms 6912 KB Output is correct
24 Correct 12 ms 7168 KB Output is correct
25 Correct 12 ms 6912 KB Output is correct
26 Correct 12 ms 6912 KB Output is correct
27 Correct 12 ms 6912 KB Output is correct
28 Correct 13 ms 6864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 14228 KB Output is correct
2 Correct 59 ms 15976 KB Output is correct
3 Correct 11 ms 6912 KB Output is correct
4 Correct 51 ms 14496 KB Output is correct
5 Correct 66 ms 17484 KB Output is correct
6 Correct 69 ms 17620 KB Output is correct
7 Correct 53 ms 16516 KB Output is correct
8 Correct 54 ms 16732 KB Output is correct
9 Correct 68 ms 17524 KB Output is correct
10 Correct 75 ms 17516 KB Output is correct
11 Correct 69 ms 17500 KB Output is correct
12 Correct 73 ms 17392 KB Output is correct
13 Correct 68 ms 17396 KB Output is correct
14 Correct 72 ms 17548 KB Output is correct
15 Correct 69 ms 17412 KB Output is correct
16 Correct 77 ms 17384 KB Output is correct
17 Correct 66 ms 17096 KB Output is correct
18 Correct 70 ms 17020 KB Output is correct
19 Correct 66 ms 17028 KB Output is correct
20 Correct 65 ms 17036 KB Output is correct
21 Correct 63 ms 17224 KB Output is correct
22 Correct 71 ms 17140 KB Output is correct
23 Correct 54 ms 14920 KB Output is correct
24 Correct 54 ms 14920 KB Output is correct
25 Correct 53 ms 15292 KB Output is correct
26 Correct 54 ms 15272 KB Output is correct
27 Correct 59 ms 16100 KB Output is correct
28 Correct 59 ms 16336 KB Output is correct
29 Correct 58 ms 16312 KB Output is correct
30 Correct 61 ms 16516 KB Output is correct
31 Correct 51 ms 14800 KB Output is correct
32 Correct 51 ms 14932 KB Output is correct
33 Correct 52 ms 15268 KB Output is correct
34 Correct 56 ms 15264 KB Output is correct
35 Correct 58 ms 16024 KB Output is correct
36 Correct 59 ms 16144 KB Output is correct
37 Correct 59 ms 16044 KB Output is correct
38 Correct 58 ms 16052 KB Output is correct
39 Correct 58 ms 15764 KB Output is correct
40 Correct 59 ms 16024 KB Output is correct
41 Correct 60 ms 16696 KB Output is correct
42 Correct 62 ms 16332 KB Output is correct
43 Correct 63 ms 16468 KB Output is correct
44 Correct 60 ms 16588 KB Output is correct
45 Correct 61 ms 16588 KB Output is correct
46 Correct 61 ms 16600 KB Output is correct
47 Correct 66 ms 15700 KB Output is correct
48 Correct 59 ms 15768 KB Output is correct
49 Correct 57 ms 15748 KB Output is correct
50 Correct 60 ms 15820 KB Output is correct
51 Correct 53 ms 15124 KB Output is correct
52 Correct 52 ms 15132 KB Output is correct
53 Correct 56 ms 15120 KB Output is correct
54 Correct 52 ms 14980 KB Output is correct
55 Correct 54 ms 15132 KB Output is correct
56 Correct 53 ms 15132 KB Output is correct
57 Correct 52 ms 15152 KB Output is correct
58 Correct 56 ms 15128 KB Output is correct
59 Correct 61 ms 15044 KB Output is correct
60 Correct 56 ms 15036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 14248 KB Output is correct
2 Correct 57 ms 15820 KB Output is correct
3 Correct 11 ms 6912 KB Output is correct
4 Correct 46 ms 14516 KB Output is correct
5 Correct 72 ms 17500 KB Output is correct
6 Correct 70 ms 17408 KB Output is correct
7 Correct 55 ms 16708 KB Output is correct
8 Correct 54 ms 16644 KB Output is correct
9 Correct 68 ms 17488 KB Output is correct
10 Correct 69 ms 17492 KB Output is correct
11 Correct 66 ms 17660 KB Output is correct
12 Correct 64 ms 17460 KB Output is correct
13 Correct 66 ms 17628 KB Output is correct
14 Correct 63 ms 17748 KB Output is correct
15 Correct 67 ms 17484 KB Output is correct
16 Correct 66 ms 17464 KB Output is correct
17 Correct 62 ms 17236 KB Output is correct
18 Correct 61 ms 17224 KB Output is correct
19 Correct 60 ms 17248 KB Output is correct
20 Correct 63 ms 17236 KB Output is correct
21 Correct 66 ms 17180 KB Output is correct
22 Correct 60 ms 17188 KB Output is correct
23 Correct 54 ms 14912 KB Output is correct
24 Correct 52 ms 14908 KB Output is correct
25 Correct 54 ms 15276 KB Output is correct
26 Correct 53 ms 15420 KB Output is correct
27 Correct 59 ms 16224 KB Output is correct
28 Correct 59 ms 16096 KB Output is correct
29 Correct 59 ms 16084 KB Output is correct
30 Correct 58 ms 16092 KB Output is correct
31 Correct 51 ms 14908 KB Output is correct
32 Correct 61 ms 14804 KB Output is correct
33 Correct 58 ms 15276 KB Output is correct
34 Correct 53 ms 15272 KB Output is correct
35 Correct 63 ms 16016 KB Output is correct
36 Correct 62 ms 16032 KB Output is correct
37 Correct 65 ms 16044 KB Output is correct
38 Correct 59 ms 16032 KB Output is correct
39 Correct 60 ms 16028 KB Output is correct
40 Correct 62 ms 16016 KB Output is correct
41 Correct 62 ms 16588 KB Output is correct
42 Correct 65 ms 16468 KB Output is correct
43 Correct 61 ms 16708 KB Output is correct
44 Correct 64 ms 16720 KB Output is correct
45 Correct 64 ms 16720 KB Output is correct
46 Correct 64 ms 16844 KB Output is correct
47 Correct 59 ms 16008 KB Output is correct
48 Correct 57 ms 15752 KB Output is correct
49 Correct 55 ms 15748 KB Output is correct
50 Correct 61 ms 15872 KB Output is correct
51 Correct 52 ms 15104 KB Output is correct
52 Correct 53 ms 15124 KB Output is correct
53 Correct 52 ms 15128 KB Output is correct
54 Correct 55 ms 14916 KB Output is correct
55 Correct 56 ms 15108 KB Output is correct
56 Correct 55 ms 15128 KB Output is correct
57 Correct 53 ms 15156 KB Output is correct
58 Correct 58 ms 15164 KB Output is correct
59 Correct 52 ms 15036 KB Output is correct
60 Correct 53 ms 14932 KB Output is correct