답안 #923704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923704 2024-02-07T15:22:04 Z daoquanglinh2007 길고양이 (JOI20_stray) C++17
15 / 100
40 ms 19564 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;

#define isz(a) (int)(a).size()
#define pii pair <int, int>
#define fi first
#define se second
#define mp make_pair

const int NM = 2e4, f[] = {0, 1, 0, 0, 1, 1};

vector <pii> adj[NM+5];
vector <int> ans;
queue <int> q;
int dep[NM+5];

void bfs(){
	for (int i = 0; i < NM; i++) dep[i] = -1;
	dep[0] = 0;
	while (!q.empty()) q.pop();
	q.push(0);
	while (!q.empty()){
		int u = q.front(); q.pop();
		for (pii _ : adj[u]){
			int v = _.fi, id = _.se;
			if (dep[v] != -1){
				ans[id] = dep[v]%3;
			}
			else{
				ans[id] = dep[u]%3;
				dep[v] = dep[u]+1;
				q.push(v);
			}
		}
	}
}

void dfs(int u, int p, int m){
	int child = isz(adj[u])-(p != -1);
	if (child == 1 || p == -1){
		for (pii _ : adj[u]){
			int v = _.fi, id = _.se;
			if (v == p) continue;
			ans[id] = f[m];
			dfs(v, u, (m+1)%6);
		}
	}
	else{
		for (pii _ : adj[u]){
			int v = _.fi, id = _.se;
			if (v == p) continue;
			if (f[(m+5)%6] == 0){
				ans[id] = 1;
				dfs(v, u, 1);
			}
			else{
				ans[id] = 0;
				dfs(v, u, 0);
			}
		}
	}
}

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++){
		adj[U[i]].push_back(mp(V[i], i));
		adj[V[i]].push_back(mp(U[i], i));
	}
	if (A > 2){
		bfs();
	}
	else{
		dfs(0, -1, 0);
	}
	return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;

int A, B;
int nMove = 0;
bool oriented = 0;
int lst = -1;
string s = "";
int tmp = -1;

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

int Move(vector<int> y){
	if (A > 2){
		if (y[1] == 0 && y[2] == 0) return 0;
		if (y[0] == 0 && y[2] == 0) return 1;
		if (y[0] == 0 && y[1] == 0) return 2;
		if (y[2] == 0) return 0;
		if (y[0] == 0) return 1;
		return 2;
	}
	++nMove;
	if (oriented){
		if (y[0] == 0 && y[1] == 0) assert(0);
		if (y[0] == 0) return lst = 1, 1;
		if (y[1] == 0) return lst = 0, 0;
		if (lst == 0) return lst = 1, 1;
		return lst = 0, 0;
	}
	if (nMove == 1){
		if (y[0] == 0 && y[1] == 1){
			oriented = 1;
			return lst = 1, 1;
		}
		if (y[1] == 0 && y[0] == 1){
			oriented = 1;
			return lst = 0, 0;
		}
		if (y[1] == 1 && y[0] > 1){
			oriented = 1;
			return lst = 1, 1;
		}
		if (y[0] == 1 && y[1] > 1){
			oriented = 1;
			return lst = 0, 0;
		}
		if (y[0] == 0 && y[1] == 2){
			s.push_back('1');
			tmp = 1;
			return lst = 1, 1;
		}
		if (y[0] == 2 && y[1] == 0){
			s.push_back('0');
			tmp = 0;
			return lst = 0, 0;
		}
		s.push_back('0');
		tmp = 1;
		return lst = 0, 0;
	}
	if (y[0] == 0 && y[1] == 0){
		oriented = 1;
		return -1;
	}
	if (y[0] == 0 && y[1] > 1){
		oriented = 1;
		return -1;
	}
	if (y[1] == 0 && y[0] > 1){
		oriented = 1;
		return -1;
	}
	if (y[0] > 0 && y[1] > 0){
		oriented = 1;
		if (lst == 0) return lst = 1, 1;
		return lst = 0, 0;
	}
	if (nMove < 4){
		if (y[0] > 0){
			s.push_back('0');
			return lst = 0, 0;
		}
		s.push_back('1');
		return lst = 1, 1;
	}
	oriented = 1;
	
	if (s == "001" && y[1] > 0) return -1;
	if (s == "010" && y[0] > 0) return -1;
	if (s == "101" && y[0] > 0) return -1;
	if (s == "110" && y[1] > 0) return -1;
	
	if (s == "100" && y[1] > 0 && tmp == 0) return -1;
	if (s == "011" && y[0] > 0 && tmp == 0) return -1;
	
	if (y[0] > 0) return lst = 0, 0;
	return lst = 1, 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15740 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 23 ms 15228 KB Output is correct
4 Correct 40 ms 16764 KB Output is correct
5 Correct 38 ms 16632 KB Output is correct
6 Correct 28 ms 15484 KB Output is correct
7 Correct 28 ms 15472 KB Output is correct
8 Correct 36 ms 16208 KB Output is correct
9 Correct 39 ms 16156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15740 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 23 ms 15228 KB Output is correct
4 Correct 40 ms 16764 KB Output is correct
5 Correct 38 ms 16632 KB Output is correct
6 Correct 28 ms 15484 KB Output is correct
7 Correct 28 ms 15472 KB Output is correct
8 Correct 36 ms 16208 KB Output is correct
9 Correct 39 ms 16156 KB Output is correct
10 Correct 26 ms 13612 KB Output is correct
11 Correct 25 ms 13492 KB Output is correct
12 Correct 26 ms 13680 KB Output is correct
13 Correct 26 ms 13696 KB Output is correct
14 Correct 27 ms 13828 KB Output is correct
15 Correct 35 ms 14028 KB Output is correct
16 Correct 32 ms 16248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 13248 KB Output is correct
2 Correct 0 ms 1608 KB Output is correct
3 Correct 22 ms 13180 KB Output is correct
4 Correct 36 ms 14588 KB Output is correct
5 Correct 32 ms 14708 KB Output is correct
6 Correct 26 ms 13140 KB Output is correct
7 Correct 26 ms 13176 KB Output is correct
8 Correct 28 ms 13940 KB Output is correct
9 Correct 31 ms 13928 KB Output is correct
10 Correct 28 ms 13692 KB Output is correct
11 Correct 36 ms 13684 KB Output is correct
12 Correct 27 ms 13684 KB Output is correct
13 Correct 27 ms 13680 KB Output is correct
14 Correct 33 ms 13924 KB Output is correct
15 Correct 31 ms 13940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 13248 KB Output is correct
2 Correct 0 ms 1608 KB Output is correct
3 Correct 22 ms 13180 KB Output is correct
4 Correct 36 ms 14588 KB Output is correct
5 Correct 32 ms 14708 KB Output is correct
6 Correct 26 ms 13140 KB Output is correct
7 Correct 26 ms 13176 KB Output is correct
8 Correct 28 ms 13940 KB Output is correct
9 Correct 31 ms 13928 KB Output is correct
10 Correct 28 ms 13692 KB Output is correct
11 Correct 36 ms 13684 KB Output is correct
12 Correct 27 ms 13684 KB Output is correct
13 Correct 27 ms 13680 KB Output is correct
14 Correct 33 ms 13924 KB Output is correct
15 Correct 31 ms 13940 KB Output is correct
16 Correct 22 ms 11640 KB Output is correct
17 Correct 22 ms 11636 KB Output is correct
18 Correct 24 ms 11600 KB Output is correct
19 Correct 25 ms 11636 KB Output is correct
20 Correct 26 ms 12400 KB Output is correct
21 Correct 26 ms 11960 KB Output is correct
22 Correct 27 ms 14036 KB Output is correct
23 Correct 25 ms 11892 KB Output is correct
24 Correct 26 ms 11896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1568 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 1 ms 1560 KB Output is correct
4 Correct 2 ms 1564 KB Output is correct
5 Correct 2 ms 1560 KB Output is correct
6 Correct 2 ms 1564 KB Output is correct
7 Correct 2 ms 1560 KB Output is correct
8 Correct 2 ms 1568 KB Output is correct
9 Correct 2 ms 1552 KB Output is correct
10 Correct 2 ms 1568 KB Output is correct
11 Correct 2 ms 1560 KB Output is correct
12 Runtime error 2 ms 1816 KB Execution killed with signal 6
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 19564 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 19244 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -