| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1100824 | Kirill22 | Hidden Sequence (info1cup18_hidden) | C++17 | 5 ms | 592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
bool isSubsequence (vector < int > v);
vector<int> findSequence(int N) {
int mx = N / 2 + 1;
vector<int> cnt(2);
for (int t = 0; t < 2; t++) {
for (int i = 1; i <= mx; i++) {
vector<int> qu(i, t);
if (isSubsequence(qu)) {
cnt[t] = i;
} else {
break;
}
}
}
int t = 0;
if (cnt[0] > cnt[1]) {
cnt[0] - N - cnt[1];
t = 1;
} else {
cnt[1] = N - cnt[0];
t = 0;
}
vector<int> lens(cnt[t] + 1);
for (int i = 0; i <= cnt[t]; i++) {
for (int j = 1; j <= mx; j++) {
vector<int> qu(i, t);
for (int k = 0; k < j; k++) {
qu.push_back(1 - t);
}
for (int k = 0; k < cnt[t] - i; k++) {
qu.push_back(t);
}
if (isSubsequence(qu)) {
lens[i] = j;
} else {
break;
}
}
}
int pos = std::max_element(lens.begin(), lens.end()) - lens.begin();
int S = std::accumulate(lens.begin(), lens.end(), 0);
lens[pos] = N - (cnt[t] + (S - lens[pos]));
vector<int> answer(lens[0], 1 - t);
for (int i = 1; i <= cnt[t]; i++) {
answer.push_back(t);
for (int j = 0; j < lens[i]; j++) {
answer.push_back(1 - t);
}
}
return answer;
}
//static int maxQ = 0;
//static vector < int > theRealAnswer;
//
//bool isSubsequence (vector < int > v)
//{
// if (v.size () > maxQ)
// maxQ = v.size ();
// int i = 0;
// for (auto it : v)
// {
// while (i < theRealAnswer.size () && it != theRealAnswer[i]) i ++;
// if (i == theRealAnswer.size ()) return 0;
// i ++;
// }
// return 1;
//}
//
//int main ()
//{
// int n, x;
// scanf ("%d", &n), maxQ = 0;
// for (int i=1; i<=n; i++)
// scanf ("%d", &x), theRealAnswer.push_back (x);
//
// vector < int > ans = findSequence (n);
// if (ans.size () != theRealAnswer.size ())
// {
// printf ("Different lengths\n");
// for (auto it : ans)
// printf ("%d ", it);
// printf ("\n");
// return 0;
// }
//
// for (int i=0; i<ans.size (); i++)
// if (ans[i] != theRealAnswer[i])
// {
// printf ("WA position %d\n", i + 1);
// for (auto it : ans)
// printf ("%d ", it);
// printf ("\n");
// return 0;
// }
// printf ("Ok, biggest queried length %d\n", maxQ);
// return 0;
//}
//
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
