Submission #710417

# Submission time Handle Problem Language Result Execution time Memory
710417 2023-03-15T08:30:05 Z emptypringlescan Stray Cat (JOI20_stray) C++17
20 / 100
58 ms 16916 KB
#include <bits/stdc++.h>
using namespace std;
 
 
vector<pair<int,int> > adj[20005],tadj[20005];
int ans[20005];
bool start=false;
int turn=0;
string s="101001";
void dfs(int x, int p, int c, int e){
	int child=0;
	for(auto i:tadj[x]){
		if(i.first==p) continue;
		child++;
	}
	if(child>1){
		start=false;
		turn=0;
		for(auto i:tadj[x]){
			if(i.first==p) continue;
			ans[i.second]=1-c;
			dfs(i.first,x,1-c,i.second);
		}
	}
	else if(child==1){
		if(!start){
			start=true;
			turn=1;
			if(e!=-1&&ans[e]==1) turn=0;
			else turn=2;
		}
		for(auto i:tadj[x]){
			if(i.first==p) continue;
			ans[i.second]=s[turn]-'0';
			turn++;
			turn%=6;
			dfs(i.first,x,ans[i.second],i.second);
		}
	}
}
vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V){
	vector<int> ret(M);
	for(int i=0; i<M; i++) ret[i]=-1;
	for(int i=0; i<M; i++){
		adj[U[i]].push_back({V[i],i});
		adj[V[i]].push_back({U[i],i});
	}
	if(A>2){
		queue<pair<int,pair<int,int> > > q;
		q.push({0,{0,-1}});
		int v[N];
		memset(v,0,sizeof(v));
		while(!q.empty()){
			int a=q.front().first,b=q.front().second.first,c=q.front().second.second;
			q.pop();
			if(v[b]) continue;
			v[b]=1;
			for(auto i:adj[b]){
				if(ret[i.second]==-1) ret[i.second]=a%3;
				if(!v[i.first]) q.push({a+1,{i.first,0}});
			}
		}
		return ret;
	}
	else{
		for(int i=0; i<M; i++){
			tadj[U[i]].push_back({V[i],i});
			tadj[V[i]].push_back({U[i],i});
		}
	}
	dfs(0,-1,1,-1);
	for(int i=0; i<M; i++) ret[i]=ans[i];
	return ret;
}
#include <bits/stdc++.h>
using namespace std;

bool start=true,confuse=false;
int mode=0;
void Init(int A, int B){
	start=true;
	confuse=false;
	if(A>2) mode=1;
}
int pre=-1;
string cur="";
int Move(vector<int> y){
	if(mode){
		if(y[0]&&y[1]) return 0;
		else if(y[1]&&y[2]) return 1;
		else if(y[0]&&y[2]) return 2;
		else if(y[0]) return 0;
		else if(y[1]) return 1;
		else if(y[2]) return 2;
		else{
			assert(false);
			return -1;
			
		}
	}
	if(!start&&!confuse){
		if(y[0]+y[1]==1){
			if(y[0]) return pre=0;
			else return pre=1;
		}
		else if(y[0]+y[1]==0) return -1;
		//assert(y[1-pre]==1);
		return pre=1-pre;
	}
	if(start){
		start=false;
		if(y[0]+y[1]==2){
			confuse=true;
			if(y[0]==2){
				cur+="00";
				return pre=0;
			}
			else if(y[1]==2){
				cur+="10";
				return pre=1;
			}
			else{
				cur+="10";
				return pre=0;
			}
		}
		else{
			if(y[0]==1) return pre=0;
			else if(y[1]==1) return pre=1;
			else{
				assert(false);
				return -1;
			}
		}
	}
	if(confuse){
		if(y[0]+y[1]>1){
			if(y[0]==0||y[1]==0){
				confuse=false;
				return -1;
			}
			return pre=1-pre;
		}
		else if(y[0]+y[1]==0){
			confuse=false;
			return -1;
		}
		else{
			if(cur.length()==4){
				if(y[0]) cur+="0";
				else cur+="1";
				if(cur=="10100"||cur=="01001"||cur=="10011"||cur=="00110"||cur=="01101"||cur=="11010"){
					cur="";
					confuse=false;
					return -1;
				}
				else{
					cur="";
					confuse=false;
					if(y[0]) return pre=0;
					else return pre=1;
				}
			}
			if(y[0]){
				cur+="0";
				return pre=0;
			}
			else{
				cur+="1";
				return pre=1;
			}
		}
	}
	return 0;
}

Compilation message

Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:54:51: warning: unused variable 'c' [-Wunused-variable]
   54 |    int a=q.front().first,b=q.front().second.first,c=q.front().second.second;
      |                                                   ^
# Verdict Execution time Memory Grader output
1 Correct 37 ms 15976 KB Output is correct
2 Correct 1 ms 1548 KB Output is correct
3 Correct 33 ms 15312 KB Output is correct
4 Correct 55 ms 16916 KB Output is correct
5 Correct 52 ms 16896 KB Output is correct
6 Correct 35 ms 15700 KB Output is correct
7 Correct 39 ms 15684 KB Output is correct
8 Correct 45 ms 16320 KB Output is correct
9 Correct 41 ms 16316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 15976 KB Output is correct
2 Correct 1 ms 1548 KB Output is correct
3 Correct 33 ms 15312 KB Output is correct
4 Correct 55 ms 16916 KB Output is correct
5 Correct 52 ms 16896 KB Output is correct
6 Correct 35 ms 15700 KB Output is correct
7 Correct 39 ms 15684 KB Output is correct
8 Correct 45 ms 16320 KB Output is correct
9 Correct 41 ms 16316 KB Output is correct
10 Correct 34 ms 13872 KB Output is correct
11 Correct 41 ms 13864 KB Output is correct
12 Correct 38 ms 13656 KB Output is correct
13 Correct 41 ms 13772 KB Output is correct
14 Correct 36 ms 13940 KB Output is correct
15 Correct 45 ms 14328 KB Output is correct
16 Correct 39 ms 16484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 13488 KB Output is correct
2 Correct 1 ms 1544 KB Output is correct
3 Correct 31 ms 13068 KB Output is correct
4 Correct 53 ms 14652 KB Output is correct
5 Correct 52 ms 14748 KB Output is correct
6 Correct 40 ms 13456 KB Output is correct
7 Correct 40 ms 13488 KB Output is correct
8 Correct 47 ms 14008 KB Output is correct
9 Correct 45 ms 13992 KB Output is correct
10 Correct 41 ms 13720 KB Output is correct
11 Correct 45 ms 13852 KB Output is correct
12 Correct 45 ms 13724 KB Output is correct
13 Correct 37 ms 13848 KB Output is correct
14 Correct 45 ms 14004 KB Output is correct
15 Correct 40 ms 14072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 13488 KB Output is correct
2 Correct 1 ms 1544 KB Output is correct
3 Correct 31 ms 13068 KB Output is correct
4 Correct 53 ms 14652 KB Output is correct
5 Correct 52 ms 14748 KB Output is correct
6 Correct 40 ms 13456 KB Output is correct
7 Correct 40 ms 13488 KB Output is correct
8 Correct 47 ms 14008 KB Output is correct
9 Correct 45 ms 13992 KB Output is correct
10 Correct 41 ms 13720 KB Output is correct
11 Correct 45 ms 13852 KB Output is correct
12 Correct 45 ms 13724 KB Output is correct
13 Correct 37 ms 13848 KB Output is correct
14 Correct 45 ms 14004 KB Output is correct
15 Correct 40 ms 14072 KB Output is correct
16 Correct 33 ms 11900 KB Output is correct
17 Correct 33 ms 11920 KB Output is correct
18 Correct 41 ms 11876 KB Output is correct
19 Correct 34 ms 11788 KB Output is correct
20 Correct 41 ms 12524 KB Output is correct
21 Correct 40 ms 12388 KB Output is correct
22 Correct 46 ms 14224 KB Output is correct
23 Correct 38 ms 12008 KB Output is correct
24 Correct 39 ms 11900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1804 KB Output is correct
2 Correct 1 ms 1544 KB Output is correct
3 Correct 2 ms 1796 KB Output is correct
4 Correct 2 ms 1796 KB Output is correct
5 Correct 3 ms 1796 KB Output is correct
6 Correct 2 ms 1796 KB Output is correct
7 Correct 2 ms 1796 KB Output is correct
8 Correct 2 ms 1792 KB Output is correct
9 Correct 2 ms 1792 KB Output is correct
10 Correct 2 ms 1796 KB Output is correct
11 Correct 3 ms 1792 KB Output is correct
12 Correct 3 ms 1780 KB Output is correct
13 Correct 3 ms 1760 KB Output is correct
14 Correct 2 ms 1796 KB Output is correct
15 Correct 2 ms 1792 KB Output is correct
16 Correct 2 ms 1800 KB Output is correct
17 Correct 2 ms 1808 KB Output is correct
18 Correct 2 ms 1796 KB Output is correct
19 Correct 2 ms 1808 KB Output is correct
20 Correct 2 ms 1796 KB Output is correct
21 Correct 2 ms 1796 KB Output is correct
22 Correct 3 ms 1796 KB Output is correct
23 Correct 2 ms 1796 KB Output is correct
24 Correct 2 ms 1796 KB Output is correct
25 Correct 2 ms 1796 KB Output is correct
26 Correct 2 ms 1804 KB Output is correct
27 Correct 2 ms 1804 KB Output is correct
28 Correct 2 ms 1804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 12376 KB Output is correct
2 Correct 40 ms 13416 KB Output is correct
3 Correct 2 ms 1544 KB Output is correct
4 Correct 37 ms 12200 KB Output is correct
5 Correct 48 ms 14484 KB Output is correct
6 Correct 58 ms 14584 KB Output is correct
7 Correct 49 ms 13680 KB Output is correct
8 Correct 53 ms 13732 KB Output is correct
9 Correct 43 ms 14644 KB Output is correct
10 Correct 58 ms 14532 KB Output is correct
11 Correct 43 ms 14616 KB Output is correct
12 Correct 48 ms 14628 KB Output is correct
13 Correct 47 ms 14696 KB Output is correct
14 Correct 55 ms 14620 KB Output is correct
15 Correct 56 ms 14684 KB Output is correct
16 Correct 48 ms 14584 KB Output is correct
17 Correct 38 ms 14264 KB Output is correct
18 Incorrect 36 ms 14416 KB Wrong Answer [6]
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 12356 KB Output is correct
2 Correct 42 ms 13248 KB Output is correct
3 Correct 1 ms 1544 KB Output is correct
4 Correct 32 ms 12120 KB Output is correct
5 Correct 49 ms 14692 KB Output is correct
6 Correct 46 ms 14620 KB Output is correct
7 Correct 51 ms 13644 KB Output is correct
8 Correct 37 ms 13784 KB Output is correct
9 Correct 48 ms 14644 KB Output is correct
10 Correct 50 ms 14528 KB Output is correct
11 Correct 57 ms 14584 KB Output is correct
12 Correct 51 ms 14712 KB Output is correct
13 Correct 44 ms 14636 KB Output is correct
14 Correct 55 ms 14572 KB Output is correct
15 Correct 44 ms 14596 KB Output is correct
16 Correct 53 ms 14604 KB Output is correct
17 Correct 49 ms 14232 KB Output is correct
18 Incorrect 43 ms 14188 KB Wrong Answer [6]
19 Halted 0 ms 0 KB -