| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 736523 | AdamGS | Rarest Insects (IOI22_insects) | C++17 | 159 ms | 456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int min_cardinality(int n) {
vector<int>A, B;
rep(i, n) {
move_inside(i);
if(press_button()==1) A.pb(i);
else {
B.pb(i);
move_outside(i);
}
}
for(auto i : A) move_outside(i);
int po=1, ko=n/(int)A.size();
stack<pair<int,int>>S;
S.push({-1, -1});
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
rep(i, A.size()) swap(A[i], A[rng()%(i+1)]);
int ile=0;
while(po<ko) {
++ile;
int sr=po+(ko-po)/4;
if(ile==1) sr=(po+ko)/2;
while(S.top().st>sr) {
B.pb(S.top().nd);
move_outside(S.top().nd);
S.pop();
}
vector<int>tmp;
rep(i, B.size()) swap(B[i], B[rng()%(i+1)]);
for(auto i : B) {
move_inside(i);
int x=press_button();
if(x>sr) {
move_outside(i);
tmp.pb(i);
continue;
}
S.push({x, i});
}
B=tmp;
bool ok=false;
for(auto i : A) {
move_inside(i);
int x=press_button();
move_outside(i);
if(x==sr) {
ok=true;
break;
}
}
if(ok) ko=sr; else po=sr+1;
}
return po;
}
컴파일 시 표준 에러 (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... | ||||
