답안 #1020297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020297 2024-07-11T19:53:14 Z ttamx 카멜레온의 사랑 (JOI20_chameleon) C++17
100 / 100
53 ms 624 KB
#include "chameleon.h"
#include <bits/stdc++.h>

using namespace std;

void Solve(int n){
	auto check=[&](vector<int> &a,int l,int r,int u){
		vector<int> b{u};
		for(int i=l;i<=r;i++)b.emplace_back(a[i]);
		return Query(b)<b.size();
	};
	auto bsearch=[&](vector<int> &a,int st,int u){
		int l=st,r=a.size();
		while(l<r){
			int m=(l+r)/2;
			if(check(a,st,m,u))r=m;
			else l=m+1;
		}
		return l;
	};
	vector<vector<int>> adj(2*n+1);
	for(int i=2;i<=2*n;i++){
		vector<int> col(i);
		function<void(int,int)> dfs=[&](int u,int c){
			if(col[u])return;
			col[u]=c;
			for(auto v:adj[u])dfs(v,3-c);
		};
		for(int j=1;j<i;j++)dfs(j,1);
		array<vector<int>,2> comp;
		for(int j=1;j<i;j++)comp[col[j]-1].emplace_back(j);
		for(auto &a:comp){
			int st=0;
			while(check(a,st,a.size()-1,i)){
				st=bsearch(a,st,i);
				int u=a[st];
				adj[i].emplace_back(u);
				adj[u].emplace_back(i);
				st++;
			}
		}
	}
	vector<int> ans(2*n+1),val(2*n+1);
	for(int i=1;i<=2*n;i++){
		auto &a=adj[i];
		if(a.size()==1){
			ans[i]=a[0];
			ans[a[0]]=i;
		}else{
			for(auto x:a)val[i]^=x;
			while(Query({i,a[0],a[1]})>1){
				rotate(a.begin(),a.begin()+1,a.end());
			}
			val[i]^=a[2];
			val[a[2]]^=i;
		}
	}
	for(int i=1;i<=2*n;i++){
		if(!ans[i])ans[i]=val[i];
		if(i<ans[i])Answer(i,ans[i]);
	}
}

Compilation message

chameleon.cpp: In lambda function:
chameleon.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   return Query(b)<b.size();
      |          ~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 19 ms 344 KB Output is correct
4 Correct 20 ms 344 KB Output is correct
5 Correct 27 ms 532 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 20 ms 520 KB Output is correct
8 Correct 26 ms 344 KB Output is correct
9 Correct 19 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 33 ms 564 KB Output is correct
4 Correct 53 ms 624 KB Output is correct
5 Correct 33 ms 344 KB Output is correct
6 Correct 34 ms 344 KB Output is correct
7 Correct 34 ms 560 KB Output is correct
8 Correct 33 ms 536 KB Output is correct
9 Correct 34 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 19 ms 344 KB Output is correct
4 Correct 20 ms 344 KB Output is correct
5 Correct 27 ms 532 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 20 ms 520 KB Output is correct
8 Correct 26 ms 344 KB Output is correct
9 Correct 19 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 33 ms 564 KB Output is correct
31 Correct 53 ms 624 KB Output is correct
32 Correct 33 ms 344 KB Output is correct
33 Correct 34 ms 344 KB Output is correct
34 Correct 34 ms 560 KB Output is correct
35 Correct 33 ms 536 KB Output is correct
36 Correct 34 ms 344 KB Output is correct
37 Correct 35 ms 548 KB Output is correct
38 Correct 20 ms 344 KB Output is correct
39 Correct 42 ms 344 KB Output is correct
40 Correct 35 ms 536 KB Output is correct
41 Correct 35 ms 344 KB Output is correct
42 Correct 20 ms 344 KB Output is correct
43 Correct 34 ms 540 KB Output is correct
44 Correct 35 ms 512 KB Output is correct
45 Correct 35 ms 344 KB Output is correct