Submission #1013114

# Submission time Handle Problem Language Result Execution time Memory
1013114 2024-07-03T08:04:27 Z Ivo_12 Stray Cat (JOI20_stray) C++17
20 / 100
39 ms 17524 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;
				}
			}
		}
	}
//	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;
	
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 16288 KB Output is correct
2 Correct 0 ms 1300 KB Output is correct
3 Correct 25 ms 15740 KB Output is correct
4 Correct 39 ms 17388 KB Output is correct
5 Correct 30 ms 17524 KB Output is correct
6 Correct 35 ms 16084 KB Output is correct
7 Correct 33 ms 16180 KB Output is correct
8 Correct 37 ms 17020 KB Output is correct
9 Correct 35 ms 16968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 16288 KB Output is correct
2 Correct 0 ms 1300 KB Output is correct
3 Correct 25 ms 15740 KB Output is correct
4 Correct 39 ms 17388 KB Output is correct
5 Correct 30 ms 17524 KB Output is correct
6 Correct 35 ms 16084 KB Output is correct
7 Correct 33 ms 16180 KB Output is correct
8 Correct 37 ms 17020 KB Output is correct
9 Correct 35 ms 16968 KB Output is correct
10 Correct 34 ms 14316 KB Output is correct
11 Correct 31 ms 14096 KB Output is correct
12 Correct 25 ms 14348 KB Output is correct
13 Correct 31 ms 14064 KB Output is correct
14 Correct 26 ms 14672 KB Output is correct
15 Correct 26 ms 14712 KB Output is correct
16 Correct 34 ms 16964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 13920 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 19 ms 13468 KB Output is correct
4 Correct 28 ms 15448 KB Output is correct
5 Correct 32 ms 15276 KB Output is correct
6 Correct 24 ms 13904 KB Output is correct
7 Correct 24 ms 13972 KB Output is correct
8 Correct 28 ms 14688 KB Output is correct
9 Correct 28 ms 14696 KB Output is correct
10 Correct 31 ms 14380 KB Output is correct
11 Correct 28 ms 14428 KB Output is correct
12 Correct 24 ms 14440 KB Output is correct
13 Correct 28 ms 14440 KB Output is correct
14 Correct 39 ms 14676 KB Output is correct
15 Correct 33 ms 14452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 13920 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 19 ms 13468 KB Output is correct
4 Correct 28 ms 15448 KB Output is correct
5 Correct 32 ms 15276 KB Output is correct
6 Correct 24 ms 13904 KB Output is correct
7 Correct 24 ms 13972 KB Output is correct
8 Correct 28 ms 14688 KB Output is correct
9 Correct 28 ms 14696 KB Output is correct
10 Correct 31 ms 14380 KB Output is correct
11 Correct 28 ms 14428 KB Output is correct
12 Correct 24 ms 14440 KB Output is correct
13 Correct 28 ms 14440 KB Output is correct
14 Correct 39 ms 14676 KB Output is correct
15 Correct 33 ms 14452 KB Output is correct
16 Correct 20 ms 12376 KB Output is correct
17 Correct 23 ms 12352 KB Output is correct
18 Correct 25 ms 12560 KB Output is correct
19 Correct 22 ms 12376 KB Output is correct
20 Correct 27 ms 13096 KB Output is correct
21 Correct 24 ms 12876 KB Output is correct
22 Correct 34 ms 14920 KB Output is correct
23 Correct 22 ms 12640 KB Output is correct
24 Correct 24 ms 12636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1824 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 2 ms 1572 KB Output is correct
4 Correct 1 ms 1572 KB Output is correct
5 Correct 1 ms 1572 KB Output is correct
6 Correct 0 ms 1568 KB Output is correct
7 Correct 1 ms 1568 KB Output is correct
8 Correct 1 ms 1572 KB Output is correct
9 Correct 1 ms 1568 KB Output is correct
10 Correct 1 ms 1568 KB Output is correct
11 Correct 2 ms 1568 KB Output is correct
12 Correct 1 ms 1572 KB Output is correct
13 Correct 1 ms 1556 KB Output is correct
14 Correct 1 ms 1572 KB Output is correct
15 Correct 2 ms 1564 KB Output is correct
16 Correct 2 ms 1568 KB Output is correct
17 Correct 1 ms 1572 KB Output is correct
18 Correct 2 ms 1572 KB Output is correct
19 Correct 2 ms 1564 KB Output is correct
20 Correct 2 ms 1564 KB Output is correct
21 Correct 1 ms 1560 KB Output is correct
22 Correct 1 ms 1572 KB Output is correct
23 Correct 1 ms 1564 KB Output is correct
24 Correct 1 ms 1568 KB Output is correct
25 Correct 1 ms 1564 KB Output is correct
26 Correct 1 ms 1560 KB Output is correct
27 Correct 1 ms 1572 KB Output is correct
28 Correct 1 ms 1572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 12212 KB Output is correct
2 Incorrect 22 ms 12392 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 12120 KB Output is correct
2 Incorrect 22 ms 12272 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -