# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
317058 | Kevin_Zhang_TW | Hidden Sequence (info1cup18_hidden) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] : ", args)
void kout() { cerr << endl; }
template<class T, class ...U>
void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
vector<int> ans{0,1,1,1,0,1,1,0,1,1,0};
bool isSubsequence(vector<int> a) {
for (int i = 0, j = 0;i < a.size();++i) {
while (j < ans.size() && ans[j] != a[i])
++j;
if (j == ans.size()) return false;
++j;
}
return true;
}
#else
#include "grader.h"
#define debug(...) 0
#define DE(...) 0
#endif
const int MAX_N = 300010;
const vector<int> zero{0}, one{1};
int n;
bool query(vector<int> a) {
if (a.size() > n) return false;
return isSubsequence(a);
}
vector<int> operator + (vector<int> a, vector<int> b) {
a.insert(end(a), AI(b));
return a;
}
vector<int> findsequence(int _n) {
n = _n;
vector<int> res;
while (res.size() < n) {
vector<int> F, B = res;
for (int i = 0;i <= res.size();++i) {
if (query( F + zero + B )) {
res = F + zero + B;
break;
}
if (query( F + one + B)) {
res = F + one + B;
break;
}
if (i == res.size()) break;
F.pb(B[0]);
B.erase(begin(B));
}
}
return res;
}
#ifdef KEV
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0);
vector<int> res = findsequence(ans.size());
if (res == ans)
cerr << "AC!\n";
else {
cerr << "WA\n";
debug(AI(res));
cerr << "Should be\n";
debug(AI(ans));
}
}
#endif