| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 497014 | abc864197532 | Hidden Sequence (info1cup18_hidden) | C++17 | 5 ms | 328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define X first
#define Y second
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l)
cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x);
#include "grader.cpp"
#else
#define test(x...) void(0);
#endif
const int N = 1001;
bool isSubsequence (vector <int> S);
pair<vector <int>, int> reduce(vector <int> a) {
vector <int> cur;
int now = -1;
for (int i : a) {
if (now == -1)
now = i;
else if (now != i) {
now = -1;
cur.pb(i);
}
}
return mp(cur, now);
}
vector <int> findSequence(int n) {
int bound = n + 1 >> 1;
int len = 0, d = 0;
if (isSubsequence(vector <int>(bound, 0))) {
d = 1;
}
for (int i = bound; i > 0; --i) {
if (isSubsequence(vector <int>(i, d))) {
len = i;
break;
}
}
int cnt[2];
if (d)
cnt[1] = len, cnt[0] = n - len;
else
cnt[0] = len, cnt[1] = n - len;
vector <int> ans;
for (int i = 0; i < n; ++i) {
if (cnt[0] == 0) {
ans.pb(1);
cnt[1]--;
continue;
}
if (cnt[1] == 0) {
ans.pb(0);
cnt[0]--;
continue;
}
vector <int> res;
int now;
tie(res, now) = reduce(ans);
if (now == -1) {
int d = 1;
if (cnt[0] < cnt[1])
d = 0;
res.pb(d ^ 1);
for (int j = 0; j < cnt[d]; ++j)
res.pb(d);
if (isSubsequence(res))
ans.pb(d ^ 1), cnt[d ^ 1]--;
else
ans.pb(d), cnt[d]--;
} else {
res.pb(now ^ 1);
for (int j = 0; j < cnt[now]; ++j)
res.pb(now);
if (isSubsequence(res))
ans.pb(now ^ 1), cnt[now ^ 1]--;
else
ans.pb(now), cnt[now]--;
}
}
return ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
