# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1126162 | Captain_Georgia | Hidden Sequence (info1cup18_hidden) | C++20 | 6 ms | 420 KiB |
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> findSequence (int N) {
int x = N / 2 + 1, typ = 0;
int low = 0, high = x;
vector<int> tmp;
while (low < high) {
int mid = (low + high + 1) / 2;
tmp.clear();
for (int i = 0;i < mid;i ++) tmp.push_back(typ);
if (isSubsequence (tmp) == true) {
low = mid;
} else {
high = mid - 1;
}
}
if (low == x) {
typ = 1;
low = 0;
high = x;
while (low < high) {
int mid = (low + high + 1) / 2;
tmp.clear();
for (int i = 0;i < mid;i ++) tmp.push_back(typ);
if (isSubsequence (tmp) == true) {
low = mid;
} else {
high = mid - 1;
}
}
assert(low < x);
}
vector<int> dre;
int cnt_zero = low;
N -= low;
for (int i = 0;i <= cnt_zero;i ++) {
low = 0;
high = min(N + 1, x);
while (low < high) {
int mid = (low + high + 1) / 2;
tmp.clear();
for (int j = 0;j < i;j ++) {
tmp.push_back(typ);
}
for (int j = 0;j < mid;j ++) {
tmp.push_back(1 - typ);
}
for (int j = i;j < cnt_zero;j ++) {
tmp.push_back(typ);
}
if (isSubsequence (tmp) == true) {
low = mid;
} else {
high = mid - 1;
}
}
if (low == x) {
dre.push_back(-1);
} else {
dre.push_back (low);
N -= low;
}
}
for (auto &v : dre) if (v == -1) {
v = N;
}
vector<int> answer;
for (int i = 0;i < dre.size();i ++) {
// cout << dre[i] << " ";
for (int j = 0;j < dre[i];j ++) answer.push_back(1 - typ);
if (i + 1 < dre.size()) answer.push_back(typ);
}
return answer;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |