Submission #212380

# Submission time Handle Problem Language Result Execution time Memory
212380 2020-03-22T20:22:07 Z Abdullah Chameleon's Love (JOI20_chameleon) C++17
44 / 100
40 ms 512 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>S(4), B(1005), adjs(1005);
vector<bool>vis(1005, 0);
int y;
void ans(int a, int b){
	if(vis[a]||vis[b])return;
	Answer(a, b);
	vis[a]=1, vis[b]=1;
	return;
}
void BS(int x, int j, int l, int r){
	if(l==r){
		adjs[x].push_back(S[j][l]);
		adjs[S[j][l]].push_back(x);
		return;
	}
	int m=(l+r)/2;
	vector<int>v1={x}, v2={x};
	for(int i=l; i<=m; i++)v1.push_back(S[j][i]);
	for(int i=m+1; i<=r; i++)v2.push_back(S[j][i]);
	if(Query(v1)!=m-l+2){
		BS(x, j, l, m);
	}
	if(Query(v2)!=r-m+1){
		BS(x, j, m+1, r);
	}
}
void Solve(int n) {
	n*=2;
	y=n;
	for(int i=1; i<=n; i++){	
		int x;
		for(int j=0; j<4&&adjs[i].size()<3; j++){
			S[j].push_back(i);
			if(Query(S[j])!=S[j].size()){
				S[j].pop_back();
				BS(i, j, 0, S[j].size()-1);
			}else{
				S[j].pop_back();
				x=j;
			}
		}
		S[x].push_back(i);
	}
	for(int i=1; i<=n; i++){
		if(adjs[i].size()==1){
			ans(i, adjs[i][0]);
	}else{
			for(int j=0; j<3; j++){
				vector<int>A={i};
				for(int a=0;a<=2; a++){
					if(a!=j)A.push_back(adjs[i][a]);
				}
				if(Query(A)==1){
					B[i].push_back(adjs[i][j]);
					B[adjs[i][j]].push_back(i);
					break;
				}
			}
		}
	}
	for(int i=1; i<=n; i++){
		if(vis[i])continue;
		for(int a:adjs[i]){
			if(a!=B[i][0]&&a!=B[i][1]){
				ans(i, a);
			}
		}
	}
}
//~ #include "chameleon.h"
//~ #include <bits/stdc++.h>
//~ using namespace std;
//~ int n;
//~ int get(int x, int l ,int r, int y){
	//~ vector<int>p;
	//~ if(y!=-1){
		//~ for(int i=l; i<=r; i++)p.push_back(i);
		//~ p.push_back(y);
		//~ return Query(p);
	//~ }else if(x==-1){
		//~ for(int i=l; i<=r; i++)	p.push_back(i);
		//~ return Query(p);
	//~ }else{
		//~ for(int i=l ; i<=r; i++){
			//~ if(i==x)continue;
			//~ p.push_back(i);
		//~ }
		//~ return Query(p);
	//~ }
//~ }
//~ int rec(int x, int l, int r){
	//~ int m=(l+r)/2;
	//~ if(l==r)	return l;
	//~ if(x<=m){
		//~ if(get(x, 1, m, -1)==get(-1, 1, m, -1))	return rec(x, 1, m);
		//~ else return rec(x, m+1, r);
	//~ }else{
		//~ if(get(-1, 1, m, -1)==get(-1, 1, m, x)) return rec(x, 1, m);
		//~ else return rec(x, m+1, r);
	//~ }
//~ }
//~ void Solve(int N) {
	//~ n=N*2;
	//~ vector<bool>vis(n+1);
	//~ for(int i=1; i<=n; i++){
		//~ if(vis[i])continue;
		//~ int j=rec(i, 1, n);
		//~ Answer(i, j);
		//~ vis[i]=1, vis[j]=1;
	//~ }
//~ }

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(Query(S[j])!=S[j].size()){
       ~~~~~~~~~~~^~~~~~~~~~~~~
chameleon.cpp:45:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   S[x].push_back(i);
      ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 31 ms 492 KB Output is correct
4 Correct 30 ms 512 KB Output is correct
5 Correct 31 ms 384 KB Output is correct
6 Correct 34 ms 384 KB Output is correct
7 Correct 30 ms 384 KB Output is correct
8 Correct 31 ms 384 KB Output is correct
9 Correct 31 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 40 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 31 ms 492 KB Output is correct
4 Correct 30 ms 512 KB Output is correct
5 Correct 31 ms 384 KB Output is correct
6 Correct 34 ms 384 KB Output is correct
7 Correct 30 ms 384 KB Output is correct
8 Correct 31 ms 384 KB Output is correct
9 Correct 31 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Incorrect 40 ms 384 KB Wrong Answer [3]
31 Halted 0 ms 0 KB -