답안 #199263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199263 2020-01-30T19:09:51 Z Bagritsevich_Stepan Hidden Sequence (info1cup18_hidden) C++14
100 / 100
85 ms 376 KB
//#include "/Users/stdc++.h"
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

#define mp make_pair
#define pb push_back
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair < int, int >
#define fs first
#define sc second
#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef long long ll;
typedef long double ld;

const int INF = 2e9;
const ll BIG_INF = 1e18;
const ll MOD = 1e9 + 7;

const int maxn = 1e5 + 5;

vector < int > findSequence(int n) {
    const int maxlen = n / 2 + 1;
    int num = 1;
    
    vector < int > seq;
    while (sz(seq) <= maxlen && isSubsequence(seq))
        seq.pb(num);
    seq.pop_back();
    
    if (sz(seq) == maxlen) {
        num ^= 1;
        
        seq.clear();
        while (isSubsequence(seq))
            seq.pb(num);
        seq.pop_back();
    }
    
    int cnt_nums = sz(seq);
    vector < int > res(n, num ^ 1);
    for (int i = 0; i < cnt_nums; i++) {
        while (sz(seq) <= maxlen && isSubsequence(seq))
            seq.insert(seq.begin(), num ^ 1);
        seq.erase(seq.begin());
        
        vector < int > rev_seq(i + 1, num);
        while (sz(rev_seq) <= maxlen && isSubsequence(rev_seq))
            rev_seq.pb(num ^ 1);
        rev_seq.pop_back();
        
        int ind = sz(seq) - (cnt_nums - i);
        if (sz(rev_seq) < maxlen) ind = n - cnt_nums - (sz(rev_seq) - (i + 1));
        res[ind + i] = num;
        seq.pop_back();
    }
    
    return res;
}

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct: Maximum length of a query = 5
2 Correct 5 ms 248 KB Output is correct: Maximum length of a query = 6
3 Correct 5 ms 376 KB Output is correct: Maximum length of a query = 5
4 Correct 5 ms 248 KB Output is correct: Maximum length of a query = 5
5 Correct 5 ms 248 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 320 KB Output is correct: Maximum length of a query = 83
2 Correct 69 ms 252 KB Output is correct: Maximum length of a query = 90
3 Correct 71 ms 248 KB Output is correct: Maximum length of a query = 96
4 Correct 41 ms 248 KB Output is correct: Maximum length of a query = 77
5 Correct 70 ms 248 KB Output is correct: Maximum length of a query = 95
6 Correct 26 ms 248 KB Output is correct: Maximum length of a query = 87
7 Correct 71 ms 248 KB Output is correct: Maximum length of a query = 97
8 Correct 64 ms 248 KB Output is correct: Maximum length of a query = 83
9 Correct 81 ms 248 KB Output is correct: Maximum length of a query = 101
10 Correct 75 ms 248 KB Output is correct: Maximum length of a query = 100
11 Correct 70 ms 320 KB Output is correct: Maximum length of a query = 96
12 Correct 69 ms 248 KB Output is correct: Maximum length of a query = 100
13 Correct 85 ms 376 KB Output is correct: Maximum length of a query = 101