# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
461196 | mtxas | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <deque>
#include <cstring>
#include <math.h>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <cave.h>
/****************************************************************************
MACROS
****************************************************************************/
#define ll long long
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define _for(a, b, c) for(int (a) = (b); (a) < (c); ++(a))
#define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); ++(a))
#define _forn(a, b, c) for(int (a) = (b); (a) > (c); (a)--)
#define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--)
#define turbo() cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define _fre() freopen("input.txt", "r", stdin)
#define sz(x) ((int)x.size())
#define all(a) a.begin(), a.end()
#define PI 3.141592654
#define mem(x, val) memset(x, val, sizeof(x))
#define pii pair<int, int>
#define mii map<int, int>
using namespace std;
/****************************************************************************
STRUCTS
****************************************************************************/
/****************************************************************************
VARIABLES
****************************************************************************/
const int maxn =5e3;
bool old[maxn];
int S[maxn], D[maxn];
int n;
/****************************************************************************
FUNCTIONS
****************************************************************************/
/****************************************************************************
MAIN
****************************************************************************/
/*int tryCombination(int X[]){
_for(i, 0, n) cout<<S[i]<<" "; cout<<'\n';
cout<<"Enter answer: "; int ans; cin>>ans;
return ans;
}
void answer(int A[], int B[]){
cout<<"D: "; _for(i, 0, n) cout<<D[i]<<" ";
}*/
void keisk(int l, int r){
_foreq(i, l, r) if(!old[i]) S[i] = !S[i];
}
int tryComb(int X[]){
int res = tryCombination(X);
return (res == -1? n: res);
}
void exploreCave(int N){
n = N;
_for(j, 0, n){
bool wasOpen = tryComb(S) > j;
int L = 0, R = N-1, k = (L+R)/2;
while(L<R){
keisk(L, k); bool isOpen = tryComb() > j; keisk(L, k);
if(isOpen != wasOpen) R = k;
else L = k+1;
k = (L+R)/2;
}
D[k] = j;
if(!wasOpen) keisk(k, k); old[k] = 1;
}
answer(S, D);
}
/*int main(){
exploreCave(4);
}*/