Submission #1006129

# Submission time Handle Problem Language Result Execution time Memory
1006129 2024-06-23T12:55:43 Z Dzadzo Chameleon's Love (JOI20_chameleon) C++17
Compilation error
0 ms 0 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 500
using namespace std;

/*int Query(const vi &p){
	for (int x:p)cout<<x<<" ";
	cout<<"\n";
	int res;
	cin>>res;
	return res;
}

*/

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 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=i;
			Answer(res,i);
			seen[res]=true;
		}
	}


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

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:108:28: error: 'res' was not declared in this scope
  108 |    if (Query({c1,c2,i})==1)res=c3;
      |                            ^~~
chameleon.cpp:109:28: error: 'res' was not declared in this scope
  109 |    if (Query({c2,c3,i})==1)res=c1;
      |                            ^~~
chameleon.cpp:110:28: error: 'res' was not declared in this scope
  110 |    if (Query({c1,c3,i})==1)res=c2;
      |                            ^~~
chameleon.cpp:112:14: error: 'res' was not declared in this scope
  112 |    marked[{i,res}]=true;
      |              ^~~
chameleon.cpp:112:10: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>')
  112 |    marked[{i,res}]=true;
      |          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from chameleon.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
chameleon.cpp:113:10: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>')
  113 |    marked[{res,i}]=true;
      |          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from chameleon.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~