Submission #338716

#TimeUsernameProblemLanguageResultExecution timeMemory
338716NicolaAbusaad2014Cave (IOI13_cave)C++14
0 / 100
318 ms748 KiB
/** * Prof.Nicola **/ #include "cave.h" #include <bits/stdc++.h> using namespace std; template<class T>void re(T&x){cin>>x;} template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);} template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);} long long n,turn[5001]={}; vector<long>arr; set<long>s; set<long>::iterator t; void con(long l,long r) { t=s.begin(); for(long i=0;i<s.size();i++){ arr[*t]=turn[*t]; t++; } for(long i=0;i<n&&r>=0;i++){ if(!s.count(i)){ if(l){ l--; continue; } arr[i]=(arr[i]^1); r--; } } } long long bin(long long l,long long r,long long x) { long long mid; int a[n]; while(l<r){ mid=(l+r)/2; con(l,mid); for(long i=0;i<n;i++){ a[i]=arr[i]; } if(tryCombination(a)==x){ l=mid+1; } else{ con(l,mid); r=mid; } } return l; } void exploreCave(int N) { n=N; arr.resize(n); int sw[n]={},ans[n]={},a[n]; long x; for(long i=0;i<N;i++){ for(long i=0;i<n;i++){ a[i]=arr[i]; } if(tryCombination(a)!=i){ con(0,N-i); } x=bin(0,N-i,i); ans[x]=i; sw[i]=(arr[i]^1); turn[i]=sw[i]; s.insert(x); } answer(sw,ans); }

Compilation message (stderr)

cave.cpp: In function 'void con(long int, long int)':
cave.cpp:20:19: warning: comparison of integer expressions of different signedness: 'long int' and 'std::set<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(long i=0;i<s.size();i++){
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...