Submission #96495

# Submission time Handle Problem Language Result Execution time Memory
96495 2019-02-09T18:02:10 Z KLPP DEL13 (info1cup18_del13) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
 
using namespace std;
int n;
bool done;
bool possible[300000];
int par[1000000];
int move[1000000];
void DFS(int mask){
	if(possible[mask])return;
	possible[mask]=true;
	int arr[n];
	for(int i=0;i<n;i++){
		arr[i]=((mask&(1<<i))>0);
	}
	int prev[n];
	int next[n];
	prev[0]=-1;
	for(int i=1;i<n;i++){
		if(arr[i-1]==1)prev[i]=prev[i-1];
		else prev[i]=i-1;
	}
	next[n-1]=n;
	for(int i=n-2;i>-1;i--){
		if(arr[i+1]==1)next[i]=next[i+1];
		else next[i]=i+1;
	}
	/*for(int i=0;i<n;i++){
		cout<<prev[i]<<" "<<next[i]<<endl;
	}*/
	for(int i=0;i<n;i++){
		if(arr[i]==0 && prev[i]!=-1 && next[i]!=n){
			int less=(1<<prev[i])+(1<<next[i]);
			if(!possible[mask+less]){
				par[mask+less]=mask;
				move[mask+less]=i;
				DFS(mask+less);
			}
		}
	}
}

int main(){
	int t;
	cin>>t;
	done=false;
	while(t--){
		cin>>n;
		if(!done){
			for(int i=0;i<(1<<n);i++)possible[i]=false;
			DFS(0);
			/*for(int mask=0;mask<(1<<n);mask++){
				for(int i=0;i<n;i++)cout<<((mask&(1<<i))>0);
				cout<<" "<<possible[mask]<<endl;
			}*/
		}
		int l;
		cin>>l;
		int MSK=(1<<n)-1;
		for(int i=0;i<l;i++){
			int x;
			cin>>x;
			x--;
			MSK-=(1<<x);
		}
		if(possible[MSK]){
			vector<int> seq;
			while(MSK!=0){
				seq.push_back(move[MSK]);
				MSK=par[MSK];
			}
			reverse(seq.begin(),seq.end());
			cout<<seq.size()<<endl;
			for(int j=0;j<seq.size();j++)cout<<seq[j]+1<<" ";
			cout<<endl;
		}
		else cout<<-1<<endl;
	}	
	return 0;
}

Compilation message

del13.cpp: In function 'void DFS(int)':
del13.cpp:36:5: error: reference to 'move' is ambiguous
     move[mask+less]=i;
     ^~~~
del13.cpp:8:5: note: candidates are: int move [1000000]
 int move[1000000];
     ^~~~
In file included from /usr/include/c++/7/deque:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from del13.cpp:1:
/usr/include/c++/7/bits/stl_deque.h:424:5: note:                 template<class _Tp> std::_Deque_iterator<_Tp, _Tp&, _Tp*> std::move(std::_Deque_iterator<_Tp, _Tp&, _Tp*>, std::_Deque_iterator<_Tp, _Tp&, _Tp*>, std::_Deque_iterator<_Tp, _Tp&, _Tp*>)
     move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
     ^~~~
In file included from /usr/include/c++/7/deque:66:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from del13.cpp:1:
/usr/include/c++/7/bits/deque.tcc:1048:5: note:                 template<class _Tp> std::_Deque_iterator<_Tp, _Tp&, _Tp*> std::move(std::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, std::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, std::_Deque_iterator<_Tp, _Tp&, _Tp*>)
     move(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first,
     ^~~~
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from del13.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:479:5: note:                 template<class _II, class _OI> _OI std::move(_II, _II, _OI)
     move(_II __first, _II __last, _OI __result)
     ^~~~
In file included from /usr/include/c++/7/bits/nested_exception.h:40:0,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from del13.cpp:1:
/usr/include/c++/7/bits/move.h:98:5: note:                 template<class _Tp> constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&)
     move(_Tp&& __t) noexcept
     ^~~~
del13.cpp: In function 'int main()':
del13.cpp:69:19: error: reference to 'move' is ambiguous
     seq.push_back(move[MSK]);
                   ^~~~
del13.cpp:8:5: note: candidates are: int move [1000000]
 int move[1000000];
     ^~~~
In file included from /usr/include/c++/7/deque:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from del13.cpp:1:
/usr/include/c++/7/bits/stl_deque.h:424:5: note:                 template<class _Tp> std::_Deque_iterator<_Tp, _Tp&, _Tp*> std::move(std::_Deque_iterator<_Tp, _Tp&, _Tp*>, std::_Deque_iterator<_Tp, _Tp&, _Tp*>, std::_Deque_iterator<_Tp, _Tp&, _Tp*>)
     move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
     ^~~~
In file included from /usr/include/c++/7/deque:66:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from del13.cpp:1:
/usr/include/c++/7/bits/deque.tcc:1048:5: note:                 template<class _Tp> std::_Deque_iterator<_Tp, _Tp&, _Tp*> std::move(std::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, std::_Deque_iterator<_Tp, const _Tp&, const _Tp*>, std::_Deque_iterator<_Tp, _Tp&, _Tp*>)
     move(_Deque_iterator<_Tp, const _Tp&, const _Tp*> __first,
     ^~~~
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from del13.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:479:5: note:                 template<class _II, class _OI> _OI std::move(_II, _II, _OI)
     move(_II __first, _II __last, _OI __result)
     ^~~~
In file included from /usr/include/c++/7/bits/nested_exception.h:40:0,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from del13.cpp:1:
/usr/include/c++/7/bits/move.h:98:5: note:                 template<class _Tp> constexpr typename std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&)
     move(_Tp&& __t) noexcept
     ^~~~
del13.cpp:74:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<seq.size();j++)cout<<seq[j]+1<<" ";
                ~^~~~~~~~~~~