답안 #245570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
245570 2020-07-06T18:57:02 Z TadijaSebez 카멜레온의 사랑 (JOI20_chameleon) C++14
64 / 100
68 ms 592 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>

void Solve(int n) {
	vector<int> groups[4];
	vector<bool> was(n*2+1,false);
	vector<vector<int>> cand(n*2+1,vector<int>());
	int sz=0;
	for(int i=1;i<=n*2;i++){
		bool ok=false;
		for(int z=0;z<sz;z++){
			function<bool(vector<int>)> work=[&](vector<int> tmp){
				tmp.pb(i);
				if(Query(tmp)==tmp.size())return false;
				tmp.pop_back();
				vector<int> mem=tmp;
				while(tmp.size()>1){
					vector<int> v[2];
					for(int j=0;j<tmp.size();j++)v[j&1].pb(tmp[j]);
					v[0].pb(i);
					int B=Query(v[0]);
					v[0].pop_back();
					if(B<=v[0].size())tmp=v[0];
					else tmp=v[1];
				}
				cand[i].pb(tmp[0]);
				cand[tmp[0]].pb(i);
				vector<int> nxt;
				for(int j:mem)if(j!=tmp[0])nxt.pb(j);
				work(nxt);
				return true;
			};
			bool now=work(groups[z]);
			if(!now&&!ok){
				groups[z].pb(i);
				ok=true;
			}
		}
		if(!ok)groups[sz++].pb(i);
	}
	set<pii> bad;
	for(int j=1;j<=n*2;j++){
		assert(cand[j].size()==1||cand[j].size()==3);
		if(cand[j].size()==3){
			int A=Query({j,cand[j][0],cand[j][1]});
			int B=Query({j,cand[j][1],cand[j][2]});
			int C=Query({j,cand[j][2],cand[j][0]});
			if(A==1)bad.insert({j,cand[j][2]});
			if(B==1)bad.insert({j,cand[j][0]});
			if(C==1)bad.insert({j,cand[j][1]});
		}
	}
	for(int j=1;j<=n*2;j++){
		if(was[j])continue;
		for(int i:cand[j]){
			if(!bad.count({i,j})&&!bad.count({j,i})){
				Answer(i,j);
				was[i]=was[j]=true;
				break;
			}
		}
	}
}

Compilation message

chameleon.cpp: In lambda function:
chameleon.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(Query(tmp)==tmp.size())return false;
        ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for(int j=0;j<tmp.size();j++)v[j&1].pb(tmp[j]);
                  ~^~~~~~~~~~~
chameleon.cpp:26:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      if(B<=v[0].size())tmp=v[0];
         ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 27 ms 428 KB Output is correct
4 Correct 27 ms 384 KB Output is correct
5 Correct 27 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 28 ms 384 KB Output is correct
8 Correct 28 ms 436 KB Output is correct
9 Correct 27 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 4 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
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 4 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 6 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 396 KB Output is correct
13 Correct 6 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
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 68 ms 524 KB Output is correct
4 Correct 62 ms 468 KB Output is correct
5 Correct 59 ms 504 KB Output is correct
6 Correct 61 ms 592 KB Output is correct
7 Correct 63 ms 384 KB Output is correct
8 Correct 67 ms 504 KB Output is correct
9 Correct 61 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 27 ms 428 KB Output is correct
4 Correct 27 ms 384 KB Output is correct
5 Correct 27 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 28 ms 384 KB Output is correct
8 Correct 28 ms 436 KB Output is correct
9 Correct 27 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 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 4 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 6 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 396 KB Output is correct
22 Correct 6 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 4 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 68 ms 524 KB Output is correct
31 Correct 62 ms 468 KB Output is correct
32 Correct 59 ms 504 KB Output is correct
33 Correct 61 ms 592 KB Output is correct
34 Correct 63 ms 384 KB Output is correct
35 Correct 67 ms 504 KB Output is correct
36 Correct 61 ms 384 KB Output is correct
37 Correct 57 ms 384 KB Output is correct
38 Correct 28 ms 384 KB Output is correct
39 Correct 59 ms 504 KB Output is correct
40 Correct 56 ms 504 KB Output is correct
41 Incorrect 58 ms 384 KB Wrong Answer [3]
42 Halted 0 ms 0 KB -