답안 #1013133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013133 2024-07-03T08:17:42 Z Ivo_12 길고양이 (JOI20_stray) C++17
91 / 100
37 ms 17164 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair < int, int >
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

namespace {

const int N = 2e4+10, M = 2e4+10, A = 4;

vector < pii > edges[N];
vector < int > oznake;
int dis[N];
int zap[N];
queue < int > q;

int pat[6] = {0, 1, 0, 0, 1, 1};

vector < int > mark( int n, int m, int a, int b, vector < int > t1, vector < int > t2 ) {
	for(int i = 0; i < m; i++) {
		edges[t1[i]].pb(mp(t2[i], i));
		edges[t2[i]].pb(mp(t1[i], i));
		oznake.pb(-1);
	}
	dis[0] = 1;
	q.push(0);
	int cur;
	int sus;
	while(!q.empty()) {
		cur = q.front();
		q.pop();
		for(int i = 0; i < (int) edges[cur].size(); i++) {
			sus = edges[cur][i].F;
			if(dis[sus] == 0) {
				q.push(sus);
				dis[sus] = dis[cur]+1;
			}
		}
	}
	if(a>=3) {
		q.push(0);
		while(!q.empty()) {
			cur = q.front();
			q.pop();
			for(int i = 0; i < (int) edges[cur].size(); i++) {
				sus = edges[cur][i].F;
				if(oznake[edges[cur][i].S] == -1) {
					if(dis[sus] > dis[cur]) q.push(sus);
					oznake[edges[cur][i].S] = (dis[cur] - 1) % 3;
				}
			}
		}
	}
	else {
		q.push(0);
		while(!q.empty()) {
			cur = q.front();
			q.pop();
			for(int i = 0; i < (int) edges[cur].size(); i++) {
				sus = edges[cur][i].F;
				if(oznake[edges[cur][i].S] == -1 && (int) edges[cur].size() > 2) {
					if(dis[sus] > dis[cur]) q.push(sus);
					oznake[edges[cur][i].S] = (pat[zap[cur]%6] + 1) % 2;
					zap[sus] = (pat[zap[cur]] + 1) % 2;
				}
				if(oznake[edges[cur][i].S] == -1 && (((int) edges[cur].size() == 2 && cur != 0) || ((int) edges[cur].size() == 1 && cur == 0))) {
					if(dis[sus] > dis[cur]) q.push(sus);
					oznake[edges[cur][i].S] = pat[(zap[cur] + 1)%6];
					zap[sus] = (zap[cur] + 1)%6;
				}
			}
		}
	}
//	for(int i = 0; i < n; i++) cout << zap[i] << " ";
//	cout << "\n";
//	for(int i = 0; i < m; i++) cout << oznake[i] << " ";
//	cout << "\n";
	return oznake;
}

}  // namespace

std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
  std::vector<int> X(M);
  return ::mark(N, M, A, B, U, V);
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair < int, int >
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

namespace {

int ga, gb;
int l[2];

int revpatt[6] = {0, 1, 0, 0, 1, 1};
vector < int > patt[6];
vector < int > ori;
int pokusaj;


void init( int a, int b ) {
	ga = a;
	gb = b;
	l[0] = 0;
	l[1] = 0;
	for(int i = 0; i < 6; i++) {
		for(int j = 0; j < 5; j++) {
			patt[i].pb(revpatt[(j+i)%6]);
		}
	}
	pokusaj = 0;
}

int move( vector < int > v ) {
	
	if(::ga>=3) {
		if(v[0] && v[1]) return 0;
		if(v[2] && v[0]) return 2;
		if(v[1] && v[2]) return 1;
		if(!(v[0] || v[1])) return 2;
		if(!(v[2] || v[0])) return 1;
		if(!(v[1] || v[2])) return 0;
	}
	::pokusaj++;
	if(::pokusaj == 1 && v[0] + v[1] == 2) {
		::ori.clear();
		if(v[0] == 1 && v[1] == 1) {
			::ori.pb(0);
			::ori.pb(1);
			l[0] = 0;
			l[1] = 1;
			return 1;
		}
		if(v[0] == 2 && v[1] == 0) {
			::ori.pb(0);
			::ori.pb(0);
			l[0] = 1;
			l[1] = 0;
			return 0;
		}
		if(v[0] == 0 && v[1] == 2) {
			::ori.pb(1);
			::ori.pb(1);
			l[0] = 0;
			l[1] = 1;
			return 1;
		}
	}
	else {
		if((::pokusaj == 2 || ::pokusaj == 3) && v[0] + v[1] == 1) {
			if(v[0] == 0) ::ori.pb(1);
			else ::ori.pb(0);
			l[0] = (int) v[0] == 1;
			l[1] = (int) v[1] == 1;
			if(v[0] == 0) return 1;
			else return 0;
		}
		else {
			if((::pokusaj == 4) && v[0] + v[1] == 1) {
				if(v[0] == 0) ::ori.pb(1);
				else ::ori.pb(0);
				for(int i = 0; i < 6; i++) if(::ori[0]==patt[i][0] && ::ori[1]==patt[i][1] && ::ori[2]==patt[i][2] && ::ori[3]==patt[i][3] && ::ori[4]==patt[i][4]) return -1;
			}
		}
	}
	::pokusaj = 10;
	if(v[0] == 0 && v[1] == 0) return -1;
	if(v[0] == 0 && v[1] > 1 && ::pokusaj != 1) {
		return -1;
	}
	if(v[0] > 1 && v[1] == 0 && ::pokusaj != 1) {
		return -1;
	}
	if(v[0] == 0 && v[1] == 1) {
		l[1] = 1;
		l[0] = 0;
		return 1;
	}
	if(v[0] == 1 && v[1] == 0) {
		l[1] = 0;
		l[0] = 1;
		return 0;
	}
	if(v[0] == 1 && v[1] > 1) {
		l[1] = 0;
		l[0] = 1;
		return 0;
	}
	if(v[0] > 1 && v[1] == 1) {
		l[1] = 1;
		l[0] = 0;
		return 1;
	}
	if(l[0]) {
		l[1] = 1;
		l[0] = 0;
		return 1;
	}
	if(l[1]) {
		l[1] = 0;
		l[0] = 1;
		return 0;
	}
	if(v[0] > v[1]) {
		l[1] = 0;
		l[0] = 1;
		return 0;
	}
	l[1] = 1;
	l[0] = 0;
	return 1;
	
}

}  // namespace

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

int Move(std::vector<int> y) {
	int tempp = ::move(y);
//	cout << y[0] << " " << y[1] << "   " << tempp << "\n";
	return tempp;
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 15988 KB Output is correct
2 Correct 0 ms 1296 KB Output is correct
3 Correct 26 ms 15480 KB Output is correct
4 Correct 29 ms 17028 KB Output is correct
5 Correct 37 ms 17164 KB Output is correct
6 Correct 26 ms 15712 KB Output is correct
7 Correct 26 ms 15824 KB Output is correct
8 Correct 29 ms 16500 KB Output is correct
9 Correct 28 ms 16516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 15988 KB Output is correct
2 Correct 0 ms 1296 KB Output is correct
3 Correct 26 ms 15480 KB Output is correct
4 Correct 29 ms 17028 KB Output is correct
5 Correct 37 ms 17164 KB Output is correct
6 Correct 26 ms 15712 KB Output is correct
7 Correct 26 ms 15824 KB Output is correct
8 Correct 29 ms 16500 KB Output is correct
9 Correct 28 ms 16516 KB Output is correct
10 Correct 26 ms 13888 KB Output is correct
11 Correct 20 ms 13952 KB Output is correct
12 Correct 21 ms 13772 KB Output is correct
13 Correct 23 ms 13960 KB Output is correct
14 Correct 24 ms 14208 KB Output is correct
15 Correct 27 ms 14468 KB Output is correct
16 Correct 26 ms 16508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 13424 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 18 ms 13136 KB Output is correct
4 Correct 28 ms 14980 KB Output is correct
5 Correct 32 ms 14960 KB Output is correct
6 Correct 23 ms 13448 KB Output is correct
7 Correct 28 ms 13512 KB Output is correct
8 Correct 27 ms 14212 KB Output is correct
9 Correct 27 ms 14212 KB Output is correct
10 Correct 24 ms 13948 KB Output is correct
11 Correct 26 ms 13948 KB Output is correct
12 Correct 26 ms 13948 KB Output is correct
13 Correct 26 ms 13816 KB Output is correct
14 Correct 26 ms 14220 KB Output is correct
15 Correct 28 ms 14208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 13424 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 18 ms 13136 KB Output is correct
4 Correct 28 ms 14980 KB Output is correct
5 Correct 32 ms 14960 KB Output is correct
6 Correct 23 ms 13448 KB Output is correct
7 Correct 28 ms 13512 KB Output is correct
8 Correct 27 ms 14212 KB Output is correct
9 Correct 27 ms 14212 KB Output is correct
10 Correct 24 ms 13948 KB Output is correct
11 Correct 26 ms 13948 KB Output is correct
12 Correct 26 ms 13948 KB Output is correct
13 Correct 26 ms 13816 KB Output is correct
14 Correct 26 ms 14220 KB Output is correct
15 Correct 28 ms 14208 KB Output is correct
16 Correct 22 ms 12148 KB Output is correct
17 Correct 24 ms 11960 KB Output is correct
18 Correct 22 ms 11888 KB Output is correct
19 Correct 24 ms 11904 KB Output is correct
20 Correct 26 ms 12524 KB Output is correct
21 Correct 27 ms 12352 KB Output is correct
22 Correct 31 ms 14436 KB Output is correct
23 Correct 23 ms 12172 KB Output is correct
24 Correct 22 ms 12164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1560 KB Output is correct
2 Correct 0 ms 1308 KB Output is correct
3 Correct 1 ms 1564 KB Output is correct
4 Correct 1 ms 1568 KB Output is correct
5 Correct 1 ms 1564 KB Output is correct
6 Correct 2 ms 1568 KB Output is correct
7 Correct 2 ms 1568 KB Output is correct
8 Correct 2 ms 1568 KB Output is correct
9 Correct 1 ms 1560 KB Output is correct
10 Correct 2 ms 1560 KB Output is correct
11 Correct 1 ms 1568 KB Output is correct
12 Correct 2 ms 1568 KB Output is correct
13 Correct 1 ms 1552 KB Output is correct
14 Correct 1 ms 1564 KB Output is correct
15 Correct 1 ms 1560 KB Output is correct
16 Correct 1 ms 1560 KB Output is correct
17 Correct 1 ms 1568 KB Output is correct
18 Correct 2 ms 1568 KB Output is correct
19 Correct 2 ms 1564 KB Output is correct
20 Correct 2 ms 1568 KB Output is correct
21 Correct 1 ms 1568 KB Output is correct
22 Correct 2 ms 1568 KB Output is correct
23 Correct 2 ms 1564 KB Output is correct
24 Correct 2 ms 1552 KB Output is correct
25 Correct 2 ms 1560 KB Output is correct
26 Correct 1 ms 1564 KB Output is correct
27 Correct 1 ms 1564 KB Output is correct
28 Correct 1 ms 1560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 11900 KB Output is correct
2 Correct 22 ms 12176 KB Output is correct
3 Correct 1 ms 1808 KB Output is correct
4 Correct 19 ms 12084 KB Output is correct
5 Correct 28 ms 13396 KB Output is correct
6 Correct 34 ms 13324 KB Output is correct
7 Correct 22 ms 12380 KB Output is correct
8 Correct 20 ms 12396 KB Output is correct
9 Correct 28 ms 13408 KB Output is correct
10 Correct 32 ms 13408 KB Output is correct
11 Correct 26 ms 13372 KB Output is correct
12 Correct 32 ms 13464 KB Output is correct
13 Correct 24 ms 13404 KB Output is correct
14 Correct 26 ms 13408 KB Output is correct
15 Correct 27 ms 13408 KB Output is correct
16 Correct 27 ms 13476 KB Output is correct
17 Correct 26 ms 13156 KB Output is correct
18 Correct 31 ms 13144 KB Output is correct
19 Correct 31 ms 13068 KB Output is correct
20 Correct 26 ms 13020 KB Output is correct
21 Correct 26 ms 13148 KB Output is correct
22 Correct 31 ms 13152 KB Output is correct
23 Correct 25 ms 12176 KB Output is correct
24 Correct 20 ms 12140 KB Output is correct
25 Correct 26 ms 12296 KB Output is correct
26 Correct 26 ms 12380 KB Output is correct
27 Correct 27 ms 12628 KB Output is correct
28 Correct 26 ms 12632 KB Output is correct
29 Correct 26 ms 12696 KB Output is correct
30 Correct 26 ms 12596 KB Output is correct
31 Correct 23 ms 12124 KB Output is correct
32 Correct 25 ms 12388 KB Output is correct
33 Correct 23 ms 12116 KB Output is correct
34 Correct 31 ms 12368 KB Output is correct
35 Correct 25 ms 12636 KB Output is correct
36 Correct 25 ms 12652 KB Output is correct
37 Correct 25 ms 12696 KB Output is correct
38 Correct 26 ms 12624 KB Output is correct
39 Correct 25 ms 12616 KB Output is correct
40 Correct 28 ms 12616 KB Output is correct
41 Correct 26 ms 12900 KB Output is correct
42 Correct 29 ms 12856 KB Output is correct
43 Correct 32 ms 12792 KB Output is correct
44 Correct 27 ms 12956 KB Output is correct
45 Correct 32 ms 12888 KB Output is correct
46 Correct 26 ms 12824 KB Output is correct
47 Correct 25 ms 12628 KB Output is correct
48 Correct 25 ms 12688 KB Output is correct
49 Correct 24 ms 12528 KB Output is correct
50 Correct 25 ms 12716 KB Output is correct
51 Correct 22 ms 12480 KB Output is correct
52 Correct 23 ms 12588 KB Output is correct
53 Correct 24 ms 12388 KB Output is correct
54 Correct 24 ms 12384 KB Output is correct
55 Correct 24 ms 12388 KB Output is correct
56 Correct 23 ms 12396 KB Output is correct
57 Correct 23 ms 12260 KB Output is correct
58 Correct 29 ms 12384 KB Output is correct
59 Correct 22 ms 12352 KB Output is correct
60 Correct 23 ms 12376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 11896 KB Output is correct
2 Correct 24 ms 11892 KB Output is correct
3 Correct 1 ms 1312 KB Output is correct
4 Correct 24 ms 12232 KB Output is correct
5 Correct 27 ms 13412 KB Output is correct
6 Correct 27 ms 13400 KB Output is correct
7 Correct 26 ms 12248 KB Output is correct
8 Correct 26 ms 12484 KB Output is correct
9 Correct 27 ms 13376 KB Output is correct
10 Correct 27 ms 13404 KB Output is correct
11 Correct 27 ms 13332 KB Output is correct
12 Correct 37 ms 13504 KB Output is correct
13 Correct 34 ms 13352 KB Output is correct
14 Correct 33 ms 13360 KB Output is correct
15 Correct 27 ms 13396 KB Output is correct
16 Correct 33 ms 13224 KB Output is correct
17 Correct 27 ms 13152 KB Output is correct
18 Correct 34 ms 13144 KB Output is correct
19 Correct 27 ms 13164 KB Output is correct
20 Correct 26 ms 13148 KB Output is correct
21 Correct 31 ms 13140 KB Output is correct
22 Correct 26 ms 13072 KB Output is correct
23 Correct 22 ms 12368 KB Output is correct
24 Correct 20 ms 12184 KB Output is correct
25 Correct 23 ms 12276 KB Output is correct
26 Correct 27 ms 12372 KB Output is correct
27 Correct 25 ms 12716 KB Output is correct
28 Correct 34 ms 12692 KB Output is correct
29 Correct 24 ms 12640 KB Output is correct
30 Correct 25 ms 12644 KB Output is correct
31 Correct 22 ms 12120 KB Output is correct
32 Correct 30 ms 12128 KB Output is correct
33 Correct 20 ms 12196 KB Output is correct
34 Correct 22 ms 12380 KB Output is correct
35 Incorrect 5 ms 3332 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -