답안 #1006134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006134 2024-06-23T13:02:07 Z Dzadzo 카멜레온의 사랑 (JOI20_chameleon) C++17
44 / 100
50 ms 5628 KB
#include <bits/stdc++.h>
#include "chameleon.h"
#define ll long long
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector <int>
#define vvi vector <vi>
#define vvvi vector <vvi>
#define vp vector <pii>
#define vvp vector <vp>
#define vb vector <bool>
#define vvb vector <vb>;
#define INF LLONG_MAX
#define MOD 1000000007
#define MAXN 1000
using namespace std;
map <vi,int> asked;
int query(const vi &p){
	vi cur=p;
	sort(cur.begin(),cur.end());
	if (asked[cur])return asked[cur];else return asked[cur]=Query(cur);
}
int n;
vvi adj(MAXN+1);
vi tp(MAXN+1);
vb seen(MAXN+1);
vi arr[3];
void dfs(int v){
	for (int to:adj[v]){
		if (!seen[to]){
			seen[to]=true;
			tp[to]=( (tp[v]==1) ? 2 : 1);
		}
	}
}
void go(int x){
	seen.assign(2*n+1,false);
	for (int i=1;i<=x;i++){
		if (!seen[i]){
			seen[i]=true;
			tp[i]=1;
			dfs(i);
		}
	}
}
vi p;
vi find(int l,int r,int id,int x){
    if (l>r)return {};
	if (l==r){
		if (query({arr[id][l],x})==1)return {arr[id][l]};
		return {};
	}
	int mid=(l+r)/2;
	vi res;

	p.clear();
	for (int i=l;i<=mid;i++)p.pb(arr[id][i]);
	p.pb(x);
	if (query(p)<mid-l+2 && l<=mid){
		vi c=find(l,mid,id,x);
		for (int y:c)res.pb(y);
	}

	p.clear();
	for (int i=mid+1;i<=r;i++)p.pb(arr[id][i]);
	p.pb(x);
	if (query(p)<r-mid+1 && r>mid){
		vi c=find(mid+1,r,id,x);
		for (int y:c)res.pb(y);
	}	

	return res;
}
void Solve(int N){
	n=N;
	for (int i=1;i<=2*n;i++){
		arr[1].clear();
		arr[2].clear();
		go(i);
		for (int j=1;j<i;j++){
			arr[tp[j]].pb(j);
		}
		vi list1=find(0,arr[1].size()-1,1,i);
		vi list2=find(0,arr[2].size()-1,2,i);
		for (int x:list1){
			adj[x].pb(i);
			adj[i].pb(x);
		}
		for (int x:list2){
			adj[x].pb(i);
			adj[i].pb(x);
		}
	}



	map <pii,int> marked;
	for (int i=1;i<=2*n;i++){
		if (adj[i].size()==3){
			int res;
			int c1=adj[i][0],c2=adj[i][1],c3=adj[i][2];
			if (query({c1,c2,i})==1)res=c3;
			if (query({c2,c3,i})==1)res=c1;
			if (query({c1,c3,i})==1)res=c2;

			marked[{i,res}]=true;
			marked[{res,i}]=true;
		}
	}
	seen.assign(2*n+1,false);
	for (int i=1;i<=2*n;i++){
		if (!seen[i]){
			int res;
			for (int x:adj[i])if (!marked[{i,x}])res=x;
			Answer(res,i);
			seen[i]=true;
			seen[res]=true;
		}
	}


}
/*signed main(){	
	int w;
	cin>>w;
	Solve(w);
}*/

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:119:12: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  119 |    seen[res]=true;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 33 ms 4436 KB Output is correct
4 Correct 34 ms 4184 KB Output is correct
5 Correct 34 ms 4432 KB Output is correct
6 Correct 33 ms 4440 KB Output is correct
7 Correct 32 ms 4176 KB Output is correct
8 Correct 33 ms 4432 KB Output is correct
9 Correct 33 ms 4440 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 1 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 1 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 2 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 600 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 Incorrect 50 ms 5628 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 33 ms 4436 KB Output is correct
4 Correct 34 ms 4184 KB Output is correct
5 Correct 34 ms 4432 KB Output is correct
6 Correct 33 ms 4440 KB Output is correct
7 Correct 32 ms 4176 KB Output is correct
8 Correct 33 ms 4432 KB Output is correct
9 Correct 33 ms 4440 KB Output is correct
10 Correct 0 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 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 2 ms 600 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Incorrect 50 ms 5628 KB Wrong Answer [3]
31 Halted 0 ms 0 KB -