# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
809201 | Boomyday | 동굴 (IOI13_cave) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!
using ii = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vii = vector<ii>;
using vpl = vector<pl>;
using vpd = vector<pd>;
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;
// pairs
#define mp make_pair
#define s second
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define len(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
const int MOD = 1e9+7; // 998244353;
const int MX = 1e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!
/*
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 5000
#define MAX_CALLS 70000
#define fail(s, x...) do { \
fprintf(stderr, s "\n", ## x); \
exit(1); \
} while(0)
#define N koala
#define realS kangaroo
#define realD possum
#define inv platypus
#define num_calls echidna
static int N;
static int realS[MAX_N];
static int realD[MAX_N];
static int inv[MAX_N];
static int num_calls;
void answer(int S[], int D[]) {
int i;
int correct = 1;
for (i = 0; i < N; ++i)
if (S[i] != realS[i] || D[i] != realD[i]) {
correct = 0;
break;
}
if (correct)
printf("CORRECT\n");
else
printf("INCORRECT\n");
for (i = 0; i < N; ++i) {
if (i > 0)
printf(" ");
printf("%d", S[i]);
}
printf("\n");
for (i = 0; i < N; ++i) {
if (i > 0)
printf(" ");
printf("%d", D[i]);
}
printf("\n");
exit(0);
}
int tryCombination(int S[]) {
int i;
if (num_calls >= MAX_CALLS) {
printf("INCORRECT\nToo many calls to tryCombination().\n");
exit(0);
}
++num_calls;
for (i = 0; i < N; ++i)
if (S[inv[i]] != realS[inv[i]])
return i;
return -1;
}
*/
void exploreCave(int N) {
unordered_set<int> toIgnore;
int vals[N];
int doors[N];
vector<int> cands;
int cc;
F0R(lev,N){
F0R(i,N){
if (toIgnore.find(i)==toIgnore.end()){
cands.pb(i);
vals[i]=0;
}
}
if (tryCombination(vals) != lev) {
cc=0;
} else cc=1;
F0R(i,N){
if (toIgnore.find(i)==toIgnore.end()){
vals[i]=cc;
}
}
while (cands.size()>1){
int half = cands.size()/2;
vi reject_cands;
F0R(i, half){
int x = cands.back();
cands.pop_back();
reject_cands.pb(x);
}
trav(i, reject_cands) {
vals[i] = 1-cc;
}
if (tryCombination(vals)!=lev){
//success!
}
else {
trav(i, reject_cands) {
vals[i]=cc;
}
trav(i, cands){
vals[i] = 1-cc;
}
cands = reject_cands;
}
}
toIgnore.insert(cands[0]);
doors[cands[0]] = lev;
}
answer(vals,doors);
}
#include "cave.h"
/*
int init() {
int i, res;
FILE *f = fopen("cave.in", "r");
if (!f)
fail("Failed to open input file.");
res = fscanf(f, "%d", &N);
for (i = 0; i < N; ++i) {
res = fscanf(f, "%d", &realS[i]);
}
for (i = 0; i < N; ++i) {
res = fscanf(f, "%d", &realD[i]);
inv[realD[i]] = i;
}
num_calls = 0;
return N;
}
int main() {
int N;
N = init();
exploreCave(N);
printf("INCORRECT\nYour solution did not call answer().\n");
return 0;
}
*/