# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
547489 | beaconmc | 동굴 (IOI13_cave) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "cave.h"
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define FOR(i, x, y) for(int i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll int
vector<vector<ll>> found;
ll test(int n){
ll ans[n];
for (auto&i : found){
ans[i[1]] = i[2];
}
ll result = tryCombination(ans);
if (result>=n || result==-1){
return 0;
}else{
return 1;
}
}
ll test2(int n, int k, int s){
ll ans[n];
FOR(i,0,k) ans[i] = s;
for (auto&i : found){
ans[i[1]] = i[2];
}
ll result = tryCombination(ans);
if (result>=n || result==-1){
return 1;
}else{
return 0;
}
}
void exploreCave(int N){
FOR(i,0,N){
ll switchd = test(i);
ll lo = 1;
ll hi = N+1;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
if (test2(N, mid, switchd)) {
hi = mid;
} else {
lo = mid + 1;
}
};
found.push_back({i, lo, switchd});
}
vector<ll> S(N);
vector<ll> D(N);
for(auto&i : found){
S[i[0]] = i[2];
D[i[0]] = i[1];
}
answer(S,D);
}