이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
/*
void answer(int s[], int d[]) {
//int n = sizeof(s)/ sizeof(s[0]);
cout << "Code: ";
for(int i = 0; i < 4; i++) cout << s[i] << " "; cout << endl;
cout << "Doors: ";
for(int i = 0; i < 4; i++) cout << d[i] << " "; cout << endl;
cout << "Exit" << endl;
}
int tryCombination(int s[]) {
//size_t n = (2 * sizeof(s) / sizeof(s[0]));
cout << "Query for doors: " << sizeof(s) << " " << sizeof(s[0]) << endl;
for(int i = 0; i < 4; i++) cout << s[i] << " "; cout << endl;
int x; cin >> x;
return x;
}
*/
void exploreCave(int n) {
//cout << n << endl;
int a[n], s[n], d[n];
for(int i = 0; i < n; i++)
a[i] = 0, s[i] = 0, d[i] = -1;
int x = tryCombination(a);
while(x != -1) {
int id;
int mn = 0, mx = n - 1;
while(mn < mx) {
int mid = (mn + mx) >> 1;
//cout << "Binsearch: " << mn << " " << mid << " " << mx << endl;
for(int i = mn; i <= mid; i++)
if(d[i] == -1) a[i] ^= 1;
int k = tryCombination(a);
for(int i = mn; i <= mid; i++)
if(d[i] == -1) a[i] ^= 1;
if(k != x)
mx = mid;
else
mn = mid + 1;
}
id = mn;
//cout << "Binsearch end: " << id << " " << x << endl; cout << endl;
d[id] = x;
a[id] ^= 1;
x = tryCombination(a);
}
for(int i = 0; i < n; i++) s[i] = a[i];
answer(s, d);
for(int i = 0; i < n; i++) {
if(d[i] != -1) continue;
s[i] ^= 1;
d[i] = tryCombination(s);
s[i] ^= 1;
}
answer(s, d);
}
/*
signed main() {
std::ios::sync_with_stdio(0);
std::cout.tie(0);
std::cin.tie(0);
int n, i, j;
cin >> n;
exploreCave(n);
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |