| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 907265 | Captain_Georgia | 동굴 (IOI13_cave) | C++17 | 154 ms | 736 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int n)
{
int v[n],res[n];
vector<int>ind;
for(int i=0;i<n;i++){
ind.push_back(i);
}
for(int i=0;i<n;i++){
for(auto &j:ind){
v[j] = 0;
}
int k = tryCombination(v);
///cerr << k << endl;
if(k == -1 || k > i){
for(auto &j:ind){
v[j] = 1;
}
int l = 1 , r = ind.size();
auto chek = [&](int ml,int mr) -> bool {
for(int j=ml;j<=mr;j++){
v[ind[j]]++;
v[ind[j]]%=2;
///cerr << v[ind[j]] << " ";
}
///cerr << endl;
int tmp = tryCombination(v);
for(int j=ml;j<=mr;j++){
v[ind[j]]++;
v[ind[j]]%=2;
///cerr << v[ind[j]] << " ";
}
///cerr << endl;
return ((tmp > i) || (tmp == -1));
};
int ans = -1;
while(l < r){
int mid=(l+r)>>1;
///cerr<<"typ 0 :: \n";
if(chek(l-1,mid-1)){
r = mid;
}
else{
l = mid + 1;
}
}
ans = r;
///cout<<ind[ans - 1]<<" "<<ind.size()<<endl;
assert(ans - 1 < ind.size());
v[ind[ans - 1]] = 0;
res[ind[ans - 1]] = i;
if(find(ind.begin(),ind.end(),ind[ans - 1]) != ind.end())
ind.erase(find(ind.begin(),ind.end(),ind[ans - 1]));
}
else{
int l = 1 , r = ind.size();
auto chek = [&](int ml,int mr) -> bool {
for(int j=ml;j<=mr;j++){
v[ind[j]]++;
v[ind[j]]%=2;
///cerr << v[ind[j]] << " ";
}
///cerr << endl;
int tmp = tryCombination(v);
///cerr << tmp << endl;
for(int j=ml;j<=mr;j++){
v[ind[j]]++;
v[ind[j]]%=2;
///cerr << v[ind[j]] << " ";
}
///cerr << endl;
return ((tmp > i) || (tmp == -1));
};
while(l < r){
int mid=(l+r)>>1;
///cerr<<"typ 1 :: \n";
if(chek(l-1,mid-1)){
r = mid;
}
else{
l = mid + 1;
}
}
int ans = r;
///cout<<ind[ans - 1]<<" "<<ind.size()<<endl;
res[ind[ans - 1]] = i;
v[ind[ans - 1]] = 1;
if(find(ind.begin(),ind.end(),ind[ans - 1]) != ind.end()){
ind.erase(find(ind.begin(),ind.end(),ind[ans - 1]));
}
}
}
answer(v,res);
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
