# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
885831 | BBart888 | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <cstring>
#include <climits>
#include <functional>
#include<cstdlib>
//#include "arc.h"
using namespace std;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long LL;
const int MAXN = 5e3 + 11;
using ll = long long;
typedef vector<int> lnum;
const int base = 1e9;
const ll mod1 = 1e9 + 7;
const ll mod2 = 1000000021;
const ll P = 31;
/*
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
if ((name.size())) {
freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
freopen((name + ".out").c_str(), "w", stdout);
}
}
*/
int N;
int arr[MAXN];
bool picked[MAXN];
int chose[MAXN];
int which_door[MAXN];
/*
int tryCombination(int S[])
{
cout << "Your array sir:\n";
for (int i = 0; i < N; i++)
cout << S[i] << " ";
cout << "\n";
for (int i = 0; i < N; i++)
cout << picked[i] << " ";
cout << '\n';
int dec;
cin >> dec;
return dec;
}
void answer(int S[], int D[]);
*/
void ustaw(int l,int r,int mode)
{
r = min(r, N-1);
for (int i = l; i <= r; i++)
arr[i] = mode;
for (int i = l; i <= r; i++)
if (picked[i])
arr[i] = chose[i];
}
void exploreCave(int n)
{
N = n;
for (int door = 0; door < n; door++)
{
ustaw(0, n - 1, 0);
//cout << "TERAZ NIE!! BINSERCZ\n";
int now =tryCombination(arr);
int what = 0;
if (now > door)
{
int opp = 1;
for (int j = 7; j >= 0; j--)
{
ustaw(0, n - 1, opp);
ustaw(0, what + (1 << j) - 1, 0);
//cout << "TERAZ BINSERCZ\n";
int ch = tryCombination(arr);
if (ch <= door)
what += (1 << j);
ustaw(0, n - 1, 0);
}
chose[what] = 0;
}
else
{
ustaw(0, n - 1, 1);
int opp = 0;
for (int j = 7; j >= 0; j--)
{
ustaw(0, n - 1, opp);
ustaw(0, what + (1 << j) - 1, 1);
//cout << "TERAZ BINSERCZ\n";
int ch = tryCombination(arr);
if (ch <= door)
what += (1 << j);
ustaw(0, n - 1, 1);
}
chose[what] = 1;
}
which_door[what] = door;
picked[what] = true;
}
//for (int i = 0; i < n; i++)
//cout << which_door[i] << " ";
//cout << "\n\n";
ustaw(0, n - 1, 0);
//for (int i = 0; i < n; i++)
//cout << arr[i] << " ";
//cout << "\n\n";
answer(arr, which_door);
}
/*
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
//setIO("time");
exploreCave(4);
return 0;
}
*/