# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45212 | 2018-04-11T21:26:44 Z | reality | Hidden Sequence (info1cup18_hidden) | C++17 | 6 ms | 640 KB |
#include "grader.h" #include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} int get(string str) { vi cnt; for (auto it : str) cnt.pb(it - '0'); return isSubsequence(cnt); } vector < int > findSequence (int N) { const int lim = (N / 2) + 1; string str = ""; int w = 1; while (str.length() < lim && get(str + "0")) str += "0"; if (str.length() == lim) { w = 0; str = ""; while (get(str + "1")) str += "1"; } vector < string > S[2]; S[0].pb(""); S[1].pb(""); for (int i = 1;i <= N;++i) S[0].pb(S[0].back() + "0"),S[1].pb(S[1].back() + "1"); const int SZ = str.length(); string answer = ""; int l = 0,r = N - SZ; for (int i = 0;i <= SZ;++i) { int ok = 1; while (ok && r > 0) { if (SZ - i + l <= i + r) { if (get(S[w][l + 1] + S[w^1][SZ - i])) answer += w + '0',++l,--r; else ok = 0; } else { if (!get(S[w^1][i + 1] + S[w][r])) answer += w + '0',++l,--r; else ok = 0; } } if (i != SZ) answer += (1 - w) + '0'; } vi ans; for (auto it : answer) ans.pb(it - '0'); return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 292 KB | Output is correct: Maximum length of a query = 5 |
2 | Correct | 2 ms | 436 KB | Output is correct: Maximum length of a query = 6 |
3 | Correct | 2 ms | 488 KB | Output is correct: Maximum length of a query = 5 |
4 | Correct | 2 ms | 488 KB | Output is correct: Maximum length of a query = 5 |
5 | Correct | 2 ms | 488 KB | Output is correct: Maximum length of a query = 4 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 488 KB | Output is correct: Maximum length of a query = 83 |
2 | Correct | 6 ms | 488 KB | Output is correct: Maximum length of a query = 90 |
3 | Correct | 6 ms | 488 KB | Output is correct: Maximum length of a query = 96 |
4 | Correct | 6 ms | 488 KB | Output is correct: Maximum length of a query = 77 |
5 | Correct | 6 ms | 640 KB | Output is correct: Maximum length of a query = 95 |
6 | Correct | 5 ms | 640 KB | Output is correct: Maximum length of a query = 87 |
7 | Correct | 6 ms | 640 KB | Output is correct: Maximum length of a query = 97 |
8 | Correct | 4 ms | 640 KB | Output is correct: Maximum length of a query = 83 |
9 | Correct | 6 ms | 640 KB | Output is correct: Maximum length of a query = 101 |
10 | Correct | 6 ms | 640 KB | Output is correct: Maximum length of a query = 100 |
11 | Correct | 5 ms | 640 KB | Output is correct: Maximum length of a query = 96 |
12 | Correct | 5 ms | 640 KB | Output is correct: Maximum length of a query = 100 |
13 | Correct | 6 ms | 640 KB | Output is correct: Maximum length of a query = 101 |