Submission #1313194

#TimeUsernameProblemLanguageResultExecution timeMemory
1313194sitingfakeCave (IOI13_cave)C++20
13 / 100
339 ms548 KiB
#include<bits/stdc++.h> #include "cave.h" using namespace std; // define //bool M1; //#define execute cerr << " Time: " << fixed << setprecision(6) << (1.0 * clock() / CLOCKS_PER_SEC) << "s\n"; //#define memory cerr << abs(&M2 - &M1)/1024.0/1024 << " MB" << "\n" #define ll long long #define ii pair <int , int> #define iii pair <int , ii> #define se second #define fi first #define all(v) (v).begin() , (v).end() #define Unique(v) sort(all(v)) , v.resize(unique(all(v)) - v.begin()) #define bit(x,i) (((x) >> (i)) & 1LL) #define flip(x,i) ((x) ^ (1LL << (i))) #define ms(d,x) memset(d , x , sizeof(d)) #define exist __exist #define ends __ends #define visit visited #define left __left #define right __right #define prev __prev #define next __next #define sitingfake 1 #define orz 1 //constant const long long mod = 1e9 + 7; const long long linf = 4557430888798830399LL; const long long nlinf = -4485090715960753727LL; const int inf = 1061109567; const int ninf = -1044266559; const int dx[] = {0 , -1 , 0 , 1}; const int dy[] = {-1 , 0 , 1 , 0}; template<typename T> bool maximize(T &a, const T &b) { if(a < b) {a = b; return 1;} return 0; } template<typename T> bool minimize(T &a, const T &b) { if(a > b) {a = b; return 1;} return 0; } void Plus(ll & a ,ll b) { b %= mod; a += b; if(a < 0) a += mod; a %= mod; return; } void Mul(ll & a, ll b) { (a *= (b % mod)) %= mod; return; } //code const int maxn = 5e3 + 7; void findState(int state[] , int n) { vector <int> p; for(int i = 0; i < n; i++) { state[i] = 0; p.push_back(i); } int cur = tryCombination(state); if(cur == -1) return; while(!p.empty()) { int left = 0 , right = p.size() - 1 , pos = -1 , val = inf; int ask[n]; for(int i = 0; i < n; i++) { ask[i] = state[i]; } while(left <= right) { int mid = (right + left) >> 1; for(int i = 0; i <= mid; i++) { ask[p[i]] = !state[p[i]]; } int d = tryCombination(ask); if(d == cur) { pos = mid; left = mid + 1; } else { right = mid - 1; } } if(pos + 1 == p.size()) { random_shuffle(all(p)); } else { for(int i = 0; i <= pos + 1; i++) { state[p[i]] ^= 1; } int d = tryCombination(state); if(d < cur) { state[p[pos + 1]] ^= 1; } else cur = d; p.erase(p.begin() + pos + 1); random_shuffle(all(p)); } } } void exploreCave(int n) { int state[n] , res[n]; findState(state , n); for(int i = 0; i < n; i++) { state[i] ^= 1; res[i] = tryCombination(state); state[i] ^= 1; } answer(state , res); } /** **/

Compilation message (stderr)

cave.cpp: In function 'void findState(int*, int)':
cave.cpp:115:27: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
  115 |             random_shuffle(all(p));
      |             ~~~~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from cave.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
cave.cpp:130:27: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
  130 |             random_shuffle(all(p));
      |             ~~~~~~~~~~~~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
#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...