Submission #212223

# Submission time Handle Problem Language Result Execution time Memory
212223 2020-03-22T14:31:38 Z pit4h Stray Cat (JOI20_stray) C++14
85 / 100
88 ms 16116 KB
#include "Anthony.h"
#include<bits/stdc++.h>
#define pii pair<int, int>
#define st first
#define nd second
using namespace std;
const int N = 2e4+1;
vector<int> mark;
vector<pii> g[N];
void dfs(int x, int p, bool cur, int len=0) {
	//~ cerr<<"dfs: "<<x<<' '<<p<<' '<<cur<<' '<<len<<' '<<g[x].size()<<'\n';
	for(auto i: g[x]) {
		if(i.st!=p) {
			if((int)g[i.st].size()!=2) {
				mark[i.nd]=cur;
				dfs(i.st, x, 1^cur);
			}
			else {
				mark[i.nd]=cur;
				if(g[x].size()!=2 && cur==1) {
					len=1;
				}
				bool nxt;
				if(len==0 || len==1 || len==4) nxt=1;
				else nxt=0;
				dfs(i.st, x, nxt, (len+1)%6);
			}
		}
	}
}
vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v) {
  mark.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});
  }
  dfs(0, 0, 0);
  return mark;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;
int a, b;
void Init(int A, int B) {
	a = A;
	b = B;
}
int col=-1;
bool good_dir=0;
vector<int> path;
vector<vector<int>>v={{0, 1, 1, 0, 0},{1, 1, 0, 0, 1},{1, 0, 0, 1, 0},{0, 0, 1, 0, 1},{0, 1, 0, 1, 1},{1, 0, 1, 1, 0}};
int Move(vector<int> y) {
	int cnt=0;
	for(int i: y) cnt+=i;
	if(col==-1) {
		if(cnt==1) {
			good_dir=1;
			if(y[0]==1) {
				col=0;
				//~ cerr<<"go to: "<<col<<'\n';
				return 0;
			}
			col=1;
			//~ cerr<<"go to: "<<col<<'\n';
			return 1;
		} 
		if(cnt>2) {
			good_dir=1;
			assert(y[0]==1 || y[1]==1);
			if(y[0]==1) {
				col=0;
				//~ cerr<<"go to: "<<col<<'\n';
				return 0;
			}
			col=1;
			//~ cerr<<"go to: "<<col<<'\n';
			return 1;
		}
		if(cnt==2) {
			if(y[1]!=0) {
				if(y[0]==1) path.push_back(0);
				else path.push_back(1);
				path.push_back(1);
				col=1;
				//~ cerr<<"go to: "<<col<<'\n';
				return 1;
			}
			path.push_back(0);
			path.push_back(0);
			col=0;
			//~ cerr<<"go to: "<<col<<'\n';
			return 0;
		}
	}
	assert(col!=-1);
	if(cnt!=1) {
		path.clear();
		good_dir=1;
	}
	if(cnt==0) {
		//~ cerr<<"go to: "<<-1<<'\n';
		return -1;
	}
	if(cnt>=2) {
		if(y[col]==0) {
			//~ cerr<<"go to: "<<-1<<'\n';
			return -1;
		}
		col=1^col;
		//~ cerr<<"go to: "<<col<<'\n';
		return col;
	}
	//~ cerr<<"path size: "<<path.size()<<' '<<good_dir<<'\n';
	if(good_dir) {
		if(y[0]==1) {
			col=0;
			//~ cerr<<"go to: "<<col<<'\n';
			return 0;
		}
		assert(y[1]==1);
		col=1;
		//~ cerr<<"go to: "<<col<<'\n';
		return 1;
	}
	if((int)path.size()==4) {
		if(y[0]==1) {
			path.push_back(0);
		}
		else {
			path.push_back(1);
		}
		if(path==v[0] || path==v[1] || path==v[2] || path==v[3] || path==v[4] || path==v[5]) {	
			//~ cerr<<"wrong\n";
			good_dir=1;
			path.clear();
			//~ cerr<<"go to: "<<-1<<'\n';
			return -1;
		}
		else { 
			good_dir=1;
			path.clear();
			if(y[0]==1) {
				col=0;
				//~ cerr<<"go to: "<<col<<'\n';
				return 0;
			}
			col=1;
			//~ cerr<<"go to: "<<col<<'\n';
			return 1;
		}
	}
	assert(path.size()>0);
	assert(cnt==1);
	//~ if(path.empty()) {
		//~ path.push_back(col);
		//~ if(y[0]==1) {
			//~ path.push_back(0);
			//~ col=0;
			//~ cerr<<"go to: "<<col<<'\n';
			//~ return 0;
		//~ }
		//~ path.push_back(1);
		//~ col=1;
		//~ cerr<<"go to: "<<col<<'\n';
		//~ return 1;
	//~ }
	if(y[0]==1) {
		path.push_back(0);
		col=0;
		//~ cerr<<"go to: "<<col<<'\n';
		return 0;
	}
	path.push_back(1);
	col=1;
	//~ cerr<<"go to: "<<col<<'\n';
	return 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 16116 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 16116 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 13812 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 55 ms 12792 KB Output is correct
4 Correct 78 ms 15612 KB Output is correct
5 Correct 82 ms 15804 KB Output is correct
6 Incorrect 53 ms 13308 KB Wrong Answer [6]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 13812 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 55 ms 12792 KB Output is correct
4 Correct 78 ms 15612 KB Output is correct
5 Correct 82 ms 15804 KB Output is correct
6 Incorrect 53 ms 13308 KB Wrong Answer [6]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1600 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 12 ms 1792 KB Output is correct
4 Correct 12 ms 1792 KB Output is correct
5 Correct 10 ms 1792 KB Output is correct
6 Correct 11 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 11 ms 1792 KB Output is correct
10 Correct 10 ms 1792 KB Output is correct
11 Correct 11 ms 1792 KB Output is correct
12 Correct 10 ms 1796 KB Output is correct
13 Correct 10 ms 1792 KB Output is correct
14 Correct 11 ms 1792 KB Output is correct
15 Correct 11 ms 1792 KB Output is correct
16 Correct 10 ms 1548 KB Output is correct
17 Correct 11 ms 1792 KB Output is correct
18 Correct 11 ms 1792 KB Output is correct
19 Correct 11 ms 2048 KB Output is correct
20 Correct 11 ms 1744 KB Output is correct
21 Correct 10 ms 1792 KB Output is correct
22 Correct 10 ms 1792 KB Output is correct
23 Correct 11 ms 1792 KB Output is correct
24 Correct 10 ms 1792 KB Output is correct
25 Correct 11 ms 1536 KB Output is correct
26 Correct 10 ms 1548 KB Output is correct
27 Correct 10 ms 1536 KB Output is correct
28 Correct 11 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 11360 KB Output is correct
2 Correct 76 ms 12584 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 52 ms 11236 KB Output is correct
5 Correct 63 ms 14196 KB Output is correct
6 Correct 71 ms 14068 KB Output is correct
7 Correct 66 ms 13300 KB Output is correct
8 Correct 57 ms 13408 KB Output is correct
9 Correct 65 ms 14180 KB Output is correct
10 Correct 72 ms 14120 KB Output is correct
11 Correct 81 ms 14068 KB Output is correct
12 Correct 70 ms 14196 KB Output is correct
13 Correct 80 ms 14020 KB Output is correct
14 Correct 69 ms 14088 KB Output is correct
15 Correct 67 ms 14068 KB Output is correct
16 Correct 69 ms 14384 KB Output is correct
17 Correct 79 ms 13776 KB Output is correct
18 Correct 67 ms 13764 KB Output is correct
19 Correct 68 ms 13872 KB Output is correct
20 Correct 74 ms 13684 KB Output is correct
21 Correct 75 ms 13952 KB Output is correct
22 Correct 69 ms 13864 KB Output is correct
23 Correct 50 ms 11604 KB Output is correct
24 Correct 71 ms 11512 KB Output is correct
25 Correct 54 ms 11860 KB Output is correct
26 Correct 59 ms 11860 KB Output is correct
27 Correct 61 ms 12532 KB Output is correct
28 Correct 68 ms 12620 KB Output is correct
29 Correct 61 ms 12696 KB Output is correct
30 Correct 59 ms 12784 KB Output is correct
31 Correct 54 ms 11364 KB Output is correct
32 Correct 56 ms 11472 KB Output is correct
33 Correct 50 ms 11932 KB Output is correct
34 Correct 53 ms 11948 KB Output is correct
35 Correct 62 ms 12512 KB Output is correct
36 Correct 77 ms 12532 KB Output is correct
37 Correct 60 ms 12540 KB Output is correct
38 Correct 60 ms 12556 KB Output is correct
39 Correct 56 ms 12584 KB Output is correct
40 Correct 60 ms 12684 KB Output is correct
41 Correct 67 ms 13316 KB Output is correct
42 Correct 83 ms 13240 KB Output is correct
43 Correct 66 ms 13284 KB Output is correct
44 Correct 67 ms 13176 KB Output is correct
45 Correct 73 ms 13160 KB Output is correct
46 Correct 71 ms 13256 KB Output is correct
47 Correct 65 ms 12472 KB Output is correct
48 Correct 78 ms 12284 KB Output is correct
49 Correct 69 ms 12276 KB Output is correct
50 Correct 71 ms 12420 KB Output is correct
51 Correct 65 ms 11516 KB Output is correct
52 Correct 77 ms 11572 KB Output is correct
53 Correct 63 ms 11516 KB Output is correct
54 Correct 58 ms 11644 KB Output is correct
55 Correct 56 ms 11592 KB Output is correct
56 Correct 62 ms 11772 KB Output is correct
57 Correct 57 ms 11380 KB Output is correct
58 Correct 56 ms 11388 KB Output is correct
59 Correct 69 ms 11620 KB Output is correct
60 Correct 76 ms 11672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 11388 KB Output is correct
2 Correct 60 ms 12340 KB Output is correct
3 Correct 11 ms 1536 KB Output is correct
4 Correct 51 ms 11264 KB Output is correct
5 Correct 88 ms 14108 KB Output is correct
6 Correct 80 ms 14088 KB Output is correct
7 Correct 53 ms 13352 KB Output is correct
8 Correct 67 ms 13224 KB Output is correct
9 Correct 74 ms 14204 KB Output is correct
10 Correct 67 ms 14096 KB Output is correct
11 Correct 88 ms 14236 KB Output is correct
12 Correct 70 ms 14068 KB Output is correct
13 Correct 74 ms 14080 KB Output is correct
14 Correct 66 ms 14068 KB Output is correct
15 Correct 79 ms 14212 KB Output is correct
16 Correct 82 ms 14076 KB Output is correct
17 Correct 69 ms 13696 KB Output is correct
18 Correct 78 ms 13772 KB Output is correct
19 Correct 72 ms 13820 KB Output is correct
20 Correct 77 ms 13760 KB Output is correct
21 Correct 73 ms 13772 KB Output is correct
22 Correct 73 ms 13772 KB Output is correct
23 Correct 57 ms 11388 KB Output is correct
24 Correct 62 ms 11492 KB Output is correct
25 Correct 57 ms 11900 KB Output is correct
26 Correct 59 ms 11908 KB Output is correct
27 Correct 68 ms 12640 KB Output is correct
28 Correct 64 ms 12760 KB Output is correct
29 Correct 68 ms 12772 KB Output is correct
30 Correct 60 ms 12784 KB Output is correct
31 Correct 56 ms 11396 KB Output is correct
32 Correct 53 ms 11396 KB Output is correct
33 Correct 53 ms 11852 KB Output is correct
34 Correct 56 ms 11872 KB Output is correct
35 Correct 64 ms 12624 KB Output is correct
36 Correct 70 ms 12496 KB Output is correct
37 Correct 62 ms 12540 KB Output is correct
38 Correct 73 ms 12544 KB Output is correct
39 Correct 66 ms 12620 KB Output is correct
40 Correct 67 ms 12532 KB Output is correct
41 Correct 84 ms 13304 KB Output is correct
42 Correct 64 ms 13308 KB Output is correct
43 Correct 76 ms 13300 KB Output is correct
44 Correct 80 ms 13156 KB Output is correct
45 Correct 86 ms 13288 KB Output is correct
46 Correct 65 ms 13180 KB Output is correct
47 Correct 59 ms 12372 KB Output is correct
48 Correct 59 ms 12284 KB Output is correct
49 Correct 75 ms 12240 KB Output is correct
50 Correct 64 ms 12404 KB Output is correct
51 Correct 55 ms 11644 KB Output is correct
52 Correct 56 ms 11500 KB Output is correct
53 Correct 59 ms 11620 KB Output is correct
54 Correct 60 ms 11528 KB Output is correct
55 Correct 57 ms 11620 KB Output is correct
56 Correct 66 ms 11504 KB Output is correct
57 Correct 58 ms 11388 KB Output is correct
58 Correct 65 ms 11348 KB Output is correct
59 Correct 55 ms 11616 KB Output is correct
60 Correct 64 ms 11644 KB Output is correct