Submission #924411

# Submission time Handle Problem Language Result Execution time Memory
924411 2024-02-09T03:14:59 Z socpite Stray Cat (JOI20_stray) C++14
100 / 100
43 ms 17292 KB
#include "Anthony.h"
#include<bits/stdc++.h>
using namespace std;


namespace {
	const int maxn = 2e4+5;
	vector<pair<int, int>> g[maxn];
	array<int, 6> pattern = {1, 0, 1, 0, 0, 1};

	int pos[maxn];
	vector<int> ans;

	void dfs(int x, int p){
		// cout << x << endl;
		int cc = 0;
		for(auto v: g[x]){
			if(v.second == p)continue;
			cc++;
		}
		if(cc == 1){
			// only child
			for(auto v: g[x]){
				if(v.second == p)continue;
				ans[v.second] = pattern[pos[x]];
				pos[v.first] = (pos[x]+1)%6;
				dfs(v.first, v.second);
			}
		} 
		else {
			for(auto v: g[x]){
				if(v.second == p)continue;
				ans[v.second] = p == -1 ? 0 : ans[p]^1;
				pos[v.first] = ans[v.second] ? 1 : 2;
				dfs(v.first, v.second);
			}
		}
	}

	void bfs(){
		queue<int> q;
		memset(pos, -1, sizeof(pos));
		pos[0] = 0;
		q.push(0);
		while(!q.empty()){
			auto x = q.front();
			q.pop();
			for(auto v: g[x]){
				if(pos[v.first] == -1){
					pos[v.first] = pos[x] + 1;
					q.push(v.first);
				}
			}
		}
	}
}  // namespace




std::vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {

	ans.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++){
			pos[i] = 0;
		}
		dfs(0, -1);
	}
	else {
		bfs();
		for(int i = 0; i < M; i++){
			ans[i] = min(pos[U[i]], pos[V[i]])%3;
		}
	}
	// for(auto v: ans)cout << v << " ";
	// cout << endl;
	return ans;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;

//1001

namespace {
  	int A, B;
  	int variable_example = 0;
	int start = 1;
	int on_line = 0;
	int prv = 0;
	int ptr = 0;
	set<array<int, 5>> check = {
		{1, 0, 1, 0, 0},
		{0, 1, 0, 0, 1},
		{1, 0, 0, 1, 1},
		{0, 0, 1, 1, 0},
		{0, 1, 1, 0, 1},
		{1, 1, 0, 1, 0}
	};
	array<int, 5> crr;
}  // namespace

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

// MAX: <; MIN: >

int Move(std::vector<int> y) {
  	if(A == 2){
		if(start){
			start = 0;
			if(y[0] + y[1] != 2){
				if(min(y[0], y[1]) == 0)prv = y[0] < y[1];
				else prv = y[0] > y[1];
				return prv;
			}
			else {
				on_line = 1;
				prv = y[0] < y[1];
				// cout << prv << endl;
				y[prv]--;
				crr[ptr++] = y[0] < y[1];
				crr[ptr++] = prv;
				return prv;
			}
		}
		else{
			if(!on_line){
				if(min(y[0], y[1]) == 0)prv = y[0] < y[1];
				else prv^=1;
				return prv;
			}
			else {
				if(y[0] + y[1] != 1){
					on_line = 0;
					ptr = 0;
					if(min(y[0], y[1]) == 0)return -1;
					else {
						prv^=1;
						return prv;
					}
				}
				else{
					prv = y[0] < y[1];
					crr[ptr++] = prv;
					if(ptr == 5){
						on_line = 0;
						if(check.find(crr) == check.end())return prv;
						else {
							prv = crr[3];
							return -1;
						}
					}
					else return prv;
				}
			}
		}
  	}
	else{
		vector<int> vec;
		for(int i = 0; i < 3; i++)if(y[i])vec.push_back(i);
		if(vec.size() == 1)return vec[0];
		else {
			if(vec[0] == 0){
				if(vec[1] == 1)return 0;
				else return 2;
			}
			else return 1;
		}
	}
}

Compilation message

Catherine.cpp:9:8: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    9 |    int variable_example = 0;
      |        ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 28 ms 15668 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 24 ms 15512 KB Output is correct
4 Correct 34 ms 17292 KB Output is correct
5 Correct 34 ms 17136 KB Output is correct
6 Correct 33 ms 16448 KB Output is correct
7 Correct 27 ms 15944 KB Output is correct
8 Correct 36 ms 16720 KB Output is correct
9 Correct 33 ms 16688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 15668 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 24 ms 15512 KB Output is correct
4 Correct 34 ms 17292 KB Output is correct
5 Correct 34 ms 17136 KB Output is correct
6 Correct 33 ms 16448 KB Output is correct
7 Correct 27 ms 15944 KB Output is correct
8 Correct 36 ms 16720 KB Output is correct
9 Correct 33 ms 16688 KB Output is correct
10 Correct 26 ms 14072 KB Output is correct
11 Correct 29 ms 14004 KB Output is correct
12 Correct 25 ms 14152 KB Output is correct
13 Correct 25 ms 14152 KB Output is correct
14 Correct 26 ms 14416 KB Output is correct
15 Correct 30 ms 14484 KB Output is correct
16 Correct 31 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 13184 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 23 ms 13196 KB Output is correct
4 Correct 35 ms 15188 KB Output is correct
5 Correct 33 ms 15176 KB Output is correct
6 Correct 27 ms 13648 KB Output is correct
7 Correct 27 ms 13760 KB Output is correct
8 Correct 41 ms 14336 KB Output is correct
9 Correct 34 ms 14344 KB Output is correct
10 Correct 31 ms 13972 KB Output is correct
11 Correct 27 ms 14164 KB Output is correct
12 Correct 34 ms 14144 KB Output is correct
13 Correct 35 ms 13968 KB Output is correct
14 Correct 32 ms 14352 KB Output is correct
15 Correct 39 ms 14240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 13184 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 23 ms 13196 KB Output is correct
4 Correct 35 ms 15188 KB Output is correct
5 Correct 33 ms 15176 KB Output is correct
6 Correct 27 ms 13648 KB Output is correct
7 Correct 27 ms 13760 KB Output is correct
8 Correct 41 ms 14336 KB Output is correct
9 Correct 34 ms 14344 KB Output is correct
10 Correct 31 ms 13972 KB Output is correct
11 Correct 27 ms 14164 KB Output is correct
12 Correct 34 ms 14144 KB Output is correct
13 Correct 35 ms 13968 KB Output is correct
14 Correct 32 ms 14352 KB Output is correct
15 Correct 39 ms 14240 KB Output is correct
16 Correct 25 ms 12036 KB Output is correct
17 Correct 34 ms 12120 KB Output is correct
18 Correct 26 ms 12100 KB Output is correct
19 Correct 28 ms 12228 KB Output is correct
20 Correct 28 ms 12872 KB Output is correct
21 Correct 33 ms 12544 KB Output is correct
22 Correct 32 ms 14672 KB Output is correct
23 Correct 26 ms 12056 KB Output is correct
24 Correct 28 ms 12152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1568 KB Output is correct
2 Correct 0 ms 1296 KB Output is correct
3 Correct 2 ms 1560 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 1560 KB Output is correct
7 Correct 2 ms 1568 KB Output is correct
8 Correct 2 ms 1568 KB Output is correct
9 Correct 2 ms 1560 KB Output is correct
10 Correct 2 ms 1556 KB Output is correct
11 Correct 1 ms 1560 KB Output is correct
12 Correct 2 ms 1560 KB Output is correct
13 Correct 1 ms 1560 KB Output is correct
14 Correct 1 ms 1560 KB Output is correct
15 Correct 1 ms 1584 KB Output is correct
16 Correct 2 ms 1584 KB Output is correct
17 Correct 2 ms 1560 KB Output is correct
18 Correct 2 ms 1560 KB Output is correct
19 Correct 2 ms 1712 KB Output is correct
20 Correct 1 ms 1560 KB Output is correct
21 Correct 2 ms 1608 KB Output is correct
22 Correct 2 ms 1560 KB Output is correct
23 Correct 2 ms 1552 KB Output is correct
24 Correct 2 ms 1568 KB Output is correct
25 Correct 1 ms 1560 KB Output is correct
26 Correct 2 ms 1568 KB Output is correct
27 Correct 2 ms 1568 KB Output is correct
28 Correct 2 ms 1568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 11368 KB Output is correct
2 Correct 33 ms 12684 KB Output is correct
3 Correct 1 ms 1308 KB Output is correct
4 Correct 24 ms 11440 KB Output is correct
5 Correct 32 ms 13764 KB Output is correct
6 Correct 36 ms 13948 KB Output is correct
7 Correct 27 ms 12916 KB Output is correct
8 Correct 27 ms 12872 KB Output is correct
9 Correct 39 ms 13932 KB Output is correct
10 Correct 33 ms 13620 KB Output is correct
11 Correct 36 ms 13676 KB Output is correct
12 Correct 32 ms 13944 KB Output is correct
13 Correct 33 ms 13776 KB Output is correct
14 Correct 43 ms 13756 KB Output is correct
15 Correct 33 ms 13968 KB Output is correct
16 Correct 31 ms 13800 KB Output is correct
17 Correct 27 ms 13616 KB Output is correct
18 Correct 27 ms 13516 KB Output is correct
19 Correct 30 ms 13684 KB Output is correct
20 Correct 34 ms 13492 KB Output is correct
21 Correct 32 ms 13480 KB Output is correct
22 Correct 32 ms 13436 KB Output is correct
23 Correct 26 ms 11392 KB Output is correct
24 Correct 26 ms 11432 KB Output is correct
25 Correct 26 ms 12008 KB Output is correct
26 Correct 25 ms 11900 KB Output is correct
27 Correct 33 ms 12632 KB Output is correct
28 Correct 28 ms 12672 KB Output is correct
29 Correct 31 ms 12644 KB Output is correct
30 Correct 27 ms 12912 KB Output is correct
31 Correct 24 ms 11388 KB Output is correct
32 Correct 26 ms 11560 KB Output is correct
33 Correct 27 ms 11932 KB Output is correct
34 Correct 27 ms 11668 KB Output is correct
35 Correct 27 ms 12480 KB Output is correct
36 Correct 38 ms 12488 KB Output is correct
37 Correct 31 ms 12500 KB Output is correct
38 Correct 27 ms 12516 KB Output is correct
39 Correct 26 ms 12356 KB Output is correct
40 Correct 30 ms 12388 KB Output is correct
41 Correct 30 ms 12924 KB Output is correct
42 Correct 30 ms 13108 KB Output is correct
43 Correct 30 ms 12916 KB Output is correct
44 Correct 28 ms 12916 KB Output is correct
45 Correct 28 ms 13172 KB Output is correct
46 Correct 28 ms 13180 KB Output is correct
47 Correct 26 ms 12400 KB Output is correct
48 Correct 31 ms 12204 KB Output is correct
49 Correct 25 ms 12152 KB Output is correct
50 Correct 27 ms 12532 KB Output is correct
51 Correct 25 ms 11712 KB Output is correct
52 Correct 26 ms 11640 KB Output is correct
53 Correct 25 ms 11632 KB Output is correct
54 Correct 30 ms 11856 KB Output is correct
55 Correct 25 ms 11640 KB Output is correct
56 Correct 25 ms 11632 KB Output is correct
57 Correct 24 ms 11904 KB Output is correct
58 Correct 25 ms 11900 KB Output is correct
59 Correct 25 ms 11644 KB Output is correct
60 Correct 26 ms 11628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 11452 KB Output is correct
2 Correct 27 ms 12388 KB Output is correct
3 Correct 1 ms 1308 KB Output is correct
4 Correct 20 ms 11264 KB Output is correct
5 Correct 32 ms 13944 KB Output is correct
6 Correct 37 ms 13932 KB Output is correct
7 Correct 27 ms 13100 KB Output is correct
8 Correct 27 ms 12936 KB Output is correct
9 Correct 31 ms 13952 KB Output is correct
10 Correct 30 ms 14040 KB Output is correct
11 Correct 32 ms 14204 KB Output is correct
12 Correct 31 ms 13728 KB Output is correct
13 Correct 31 ms 13952 KB Output is correct
14 Correct 38 ms 14176 KB Output is correct
15 Correct 32 ms 13948 KB Output is correct
16 Correct 30 ms 13924 KB Output is correct
17 Correct 27 ms 13688 KB Output is correct
18 Correct 28 ms 13692 KB Output is correct
19 Correct 28 ms 13692 KB Output is correct
20 Correct 28 ms 13576 KB Output is correct
21 Correct 34 ms 13380 KB Output is correct
22 Correct 28 ms 13692 KB Output is correct
23 Correct 24 ms 11384 KB Output is correct
24 Correct 25 ms 11388 KB Output is correct
25 Correct 25 ms 11892 KB Output is correct
26 Correct 25 ms 11900 KB Output is correct
27 Correct 27 ms 12480 KB Output is correct
28 Correct 28 ms 12904 KB Output is correct
29 Correct 27 ms 12916 KB Output is correct
30 Correct 26 ms 12920 KB Output is correct
31 Correct 24 ms 11380 KB Output is correct
32 Correct 25 ms 11388 KB Output is correct
33 Correct 25 ms 11904 KB Output is correct
34 Correct 25 ms 12396 KB Output is correct
35 Correct 27 ms 12416 KB Output is correct
36 Correct 26 ms 12420 KB Output is correct
37 Correct 26 ms 12404 KB Output is correct
38 Correct 27 ms 12412 KB Output is correct
39 Correct 27 ms 12416 KB Output is correct
40 Correct 27 ms 12412 KB Output is correct
41 Correct 28 ms 12936 KB Output is correct
42 Correct 27 ms 13132 KB Output is correct
43 Correct 28 ms 13128 KB Output is correct
44 Correct 30 ms 13180 KB Output is correct
45 Correct 28 ms 13180 KB Output is correct
46 Correct 28 ms 13172 KB Output is correct
47 Correct 26 ms 12416 KB Output is correct
48 Correct 26 ms 12404 KB Output is correct
49 Correct 26 ms 12420 KB Output is correct
50 Correct 27 ms 12404 KB Output is correct
51 Correct 26 ms 11632 KB Output is correct
52 Correct 25 ms 11648 KB Output is correct
53 Correct 26 ms 11628 KB Output is correct
54 Correct 26 ms 11636 KB Output is correct
55 Correct 26 ms 11632 KB Output is correct
56 Correct 25 ms 11644 KB Output is correct
57 Correct 25 ms 11884 KB Output is correct
58 Correct 25 ms 11900 KB Output is correct
59 Correct 25 ms 11632 KB Output is correct
60 Correct 26 ms 11692 KB Output is correct