Submission #1313233

#TimeUsernameProblemLanguageResultExecution timeMemory
1313233sitingfakeCave (IOI13_cave)C++20
100 / 100
355 ms488 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 exploreCave(int n) { int state[n] , res[n]; ms(state , 0); ms(res , -1); for(int door = 0; door < n; door++) { int cur = tryCombination(state); int left = 0 , right = n - 1 , pos = -1; while(left <= right) { int mid = (left + right) >> 1; for(int i = 0; i <= mid; i++) { if(res[i] == -1) state[i] = 1; } int d = tryCombination(state); if(cur > door || cur == -1) { // door I is open if(d <= door && d != -1) { pos = mid; right = mid - 1; } else left = mid + 1; } else { // door I is close if(d > door || d == -1) { pos = mid; right = mid - 1; } else left = mid + 1; } for(int i = 0; i <= mid; i++) { if(res[i] == -1) state[i] = 0; } } if(cur <= door && cur != -1) state[pos] = 1; res[pos] = door; } answer(state , res); } /** **/
#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...