# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
783944 | Boas | 동굴 (IOI13_cave) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
map<vi, int> tryCombi;
int ownTryCombination(vi &switches)
{
cerr << endl
<< "TryCombination: ";
for (int t : switches)
{
cerr << t << " ";
}
cerr << endl;
int res;
if (tryCombi.find(switches) != tryCombi.end())
{
res = tryCombi[switches];
}
else
{
res = tryCombination(switches.data());
tryCombi[switches] = res;
}
cerr << "Result: " << res << endl;
return res;
}
void exploreCave(int N)
{
vi switches(N, 0);
vi minDist(N);
vi maxDist(N, N);
int d = ownTryCombination(switches);
int nd = 0;
int iter = 0;
while (d != -1)
{
if (nd == -1)
break;
for (int i = 0; i < N; i++)
{
iter++;
if (iter > 500)
{
cerr << 'a';
}
if (minDist[i] > nd)
{
continue;
}
if (minDist[i] == maxDist[i])
continue;
switches[i] = !switches[i];
nd = ownTryCombination(switches);
if (nd == -1)
break;
if (nd == d)
{
cerr << "minDist[" << i << "] = " << d + 1 << endl;
minDist[i] = d + 1;
switches[i] = !switches[i];
d = nd;
}
else if (nd > d)
{
cerr << "min&maxDist[" << i << "] = " << d << endl;
minDist[i] = d;
maxDist[i] = d;
d = nd;
}
else
{
cerr << "min&maxDist[" << i << "] = " << nd << endl;
minDist[i] = nd;
maxDist[i] = nd;
switches[i] = !switches[i];
// i--;
}
}
if (nd == -1)
break;
}
for (int i = 0; i < N; i++)
{
if (minDist[i] == maxDist[i])
continue;
switches[i] = !switches[i];
int d = ownTryCombination(switches);
minDist[i] = d;
maxDist[i] = d;
switches[i] = !switches[i];
}
answer(switches.data(), minDist.data());
cerr << endl;
}