답안 #444865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
444865 2021-07-15T16:20:22 Z kig9981 길고양이 (JOI20_stray) C++17
15 / 100
59 ms 16404 KB
#include "Anthony.h"
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
vector<pair<int,int>> adj[20000];
int dist[20000];
 
std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) {
	vector<int> X(M,-1);
	queue<pair<int,int>> Q;
	memset(dist,-1,sizeof(dist));
	for(int i=0;i<M;i++) {
		adj[U[i]].emplace_back(V[i],i);
		adj[V[i]].emplace_back(U[i],i);
	}
	dist[0]=0;
	for(auto[n,t]: adj[0]) {
		dist[n]=1; X[t]=0;
		Q.emplace(n,t);
	}
	while(!Q.empty()) {
		auto[c,p]=Q.front();
		Q.pop();
		for(auto[n,t]: adj[c]) {
			if(dist[n]==-1) {
				dist[n]=dist[c]+1;
				if(A==2) {
					if(X[p]>1) {
						if(adj[c].size()==2) X[t]=(X[p]-1)%6+2;
						else X[t]=!(X[p]==3 || X[p]==6 || X[p]==7);
					}
					else {
						if(adj[c].size()==2) X[t]=X[p]+3;
						else X[t]=X[p]^1;
					}
				}
				else X[t]=min(dist[c],dist[n])%3;
				Q.emplace(n,t);
			}
			else if(X[t]==-1) X[t]=min(dist[c],dist[n])%3;
		}
	}
	if(A==2) for(auto &p: X) p=p==1 || p==3 || p==6 || p==7;
	return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
int A, r;
bool d;
string s;
 
void Init(int A, int B) {
	::A=A;
	r=-1; d=false; s="";
}

int Move(std::vector<int> y) {
	if(r!=-1) y[r]++;
	if(A==2) {
		if(d) {
			for(int i=0;i<2;i++) if(y[i]==0) return r=i^1;
			for(int i=0;i<2;i++) if(y[i]==1 && y[i]-(i==r)==1) return r=i;
		}
		else {
			if(y[0]+y[1]>2) {
				d=true;
				if(r!=-1 && --y[r]==0) return -1;
				else {
					for(int i=0;i<2;i++) if(y[i]==1 && y[i]+(i==r)==1) return r=i;
				}
			}
			if(y[0]+y[1]==1) {
				d=true;
				for(int i=0;i<2;i++) if(y[i]) {
					if(i==r) return -1;
					return r=i;
				}
			}
			if(s.size()==6) {
				d=true;
				for(int i=0;i<6;i++) {
					bool valid=true;
					for(int j=0;j<4;j++) valid&=s[(i+j)%6]=='0'+j/2;
					if(valid) {
						for(int i=0;i<2;i++) if(y[i]==1 && y[i]-(i==r)==1) return r=i;
					}
				}
				return -1;
			}
			if(r!=-1) y[r]--;
			for(int i=0;i<2;i++) if(y[i]) {
				s.push_back('0'+i);
				return r=i;
			}
		}
	}
	else {
		for(int i=0;i<3;i++) if(y[i]==0 && y[(i+1)%3]==0) return r=(i+2)%3;
		for(int i=0;i<3;i++) if(y[i]==0) return r=(i+1)%3;
	}
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
   67 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 15428 KB Output is correct
2 Correct 1 ms 1128 KB Output is correct
3 Correct 36 ms 14800 KB Output is correct
4 Correct 55 ms 16404 KB Output is correct
5 Correct 57 ms 16332 KB Output is correct
6 Correct 41 ms 15152 KB Output is correct
7 Correct 43 ms 15112 KB Output is correct
8 Correct 49 ms 15852 KB Output is correct
9 Correct 53 ms 15908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 15428 KB Output is correct
2 Correct 1 ms 1128 KB Output is correct
3 Correct 36 ms 14800 KB Output is correct
4 Correct 55 ms 16404 KB Output is correct
5 Correct 57 ms 16332 KB Output is correct
6 Correct 41 ms 15152 KB Output is correct
7 Correct 43 ms 15112 KB Output is correct
8 Correct 49 ms 15852 KB Output is correct
9 Correct 53 ms 15908 KB Output is correct
10 Correct 39 ms 13380 KB Output is correct
11 Correct 43 ms 13224 KB Output is correct
12 Correct 40 ms 13260 KB Output is correct
13 Correct 42 ms 13144 KB Output is correct
14 Correct 41 ms 13560 KB Output is correct
15 Correct 46 ms 13904 KB Output is correct
16 Correct 49 ms 15880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 12964 KB Output is correct
2 Correct 1 ms 1128 KB Output is correct
3 Correct 34 ms 12680 KB Output is correct
4 Correct 59 ms 14224 KB Output is correct
5 Correct 53 ms 14316 KB Output is correct
6 Correct 43 ms 13028 KB Output is correct
7 Correct 41 ms 12924 KB Output is correct
8 Correct 48 ms 13564 KB Output is correct
9 Correct 49 ms 13568 KB Output is correct
10 Correct 47 ms 13352 KB Output is correct
11 Correct 44 ms 13328 KB Output is correct
12 Correct 45 ms 13312 KB Output is correct
13 Correct 44 ms 13272 KB Output is correct
14 Correct 49 ms 13824 KB Output is correct
15 Correct 49 ms 13608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 12964 KB Output is correct
2 Correct 1 ms 1128 KB Output is correct
3 Correct 34 ms 12680 KB Output is correct
4 Correct 59 ms 14224 KB Output is correct
5 Correct 53 ms 14316 KB Output is correct
6 Correct 43 ms 13028 KB Output is correct
7 Correct 41 ms 12924 KB Output is correct
8 Correct 48 ms 13564 KB Output is correct
9 Correct 49 ms 13568 KB Output is correct
10 Correct 47 ms 13352 KB Output is correct
11 Correct 44 ms 13328 KB Output is correct
12 Correct 45 ms 13312 KB Output is correct
13 Correct 44 ms 13272 KB Output is correct
14 Correct 49 ms 13824 KB Output is correct
15 Correct 49 ms 13608 KB Output is correct
16 Correct 40 ms 11528 KB Output is correct
17 Correct 38 ms 11508 KB Output is correct
18 Correct 40 ms 11480 KB Output is correct
19 Correct 38 ms 11424 KB Output is correct
20 Correct 43 ms 11972 KB Output is correct
21 Correct 41 ms 11780 KB Output is correct
22 Correct 47 ms 13720 KB Output is correct
23 Correct 38 ms 11524 KB Output is correct
24 Correct 39 ms 11516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1400 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 2 ms 1392 KB Output is correct
4 Correct 2 ms 1392 KB Output is correct
5 Correct 2 ms 1316 KB Output is correct
6 Correct 2 ms 1392 KB Output is correct
7 Correct 2 ms 1392 KB Output is correct
8 Incorrect 2 ms 1392 KB Wrong Answer [5]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11176 KB Output is correct
2 Correct 42 ms 11960 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 34 ms 11340 KB Output is correct
5 Correct 48 ms 12692 KB Output is correct
6 Incorrect 37 ms 11776 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11136 KB Output is correct
2 Correct 41 ms 11948 KB Output is correct
3 Correct 2 ms 1132 KB Output is correct
4 Correct 33 ms 11520 KB Output is correct
5 Correct 49 ms 12708 KB Output is correct
6 Incorrect 36 ms 11816 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -