답안 #67188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67188 2018-08-13T14:04:47 Z MrTEK Hidden Sequence (info1cup18_hidden) C++14
100 / 100
14 ms 568 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e3 + 5;
const int M = 4;
const int SQ = 350;
const int MOD = 998244353;
 
vector < int > findSequence (int N)
{
    vector < int > ans (N, 0),v0,v1,v;
    int sif,bir,cnt_0 = 0,cnt_1 = 0;
    for (int i = 0 ; i < N ; i++) {
        v0.pb(0);
        v1.pb(1);
        if (isSubsequence(v0) == false) {
            sif = i;
            bir = N - sif;
            break;
        }
        else if(isSubsequence(v1) == false) {
            bir = i;
            sif = N - bir;
            break;
        }
    }
    for (int i = 0 ; i < N ; i++) {
        v.clear();
        if (cnt_0 + 1 + bir - cnt_1 <= N / 2 + 1) {
            for (int i = 1 ; i <= cnt_0 + 1 ; i++)
                v.pb(0);
            for (int i = 1 ; i <= bir - cnt_1 ; i++)
                v.pb(1);
            if(isSubsequence(v)) cnt_0++,ans[i] = 0;           
            else cnt_1++,ans[i] = 1;
            continue;
        }
        else {
            for (int i = 1 ; i <= cnt_1 + 1 ; i++)
                v.pb(1);
            for (int i = 1 ; i <= sif - cnt_0 ; i++)
                v.pb(0);
            if(isSubsequence(v)) cnt_1++,ans[i] = 1;           
            else cnt_0++,ans[i] = 0;
            continue;
        }
    }
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:48:23: warning: 'bir' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (cnt_0 + 1 + bir - cnt_1 <= N / 2 + 1) {
             ~~~~~~~~~~^~~~~
hidden.cpp:60:39: warning: 'sif' may be used uninitialized in this function [-Wmaybe-uninitialized]
             for (int i = 1 ; i <= sif - cnt_0 ; i++)
                                   ~~~~^~~~~~~
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 2 ms 404 KB Output is correct: Maximum length of a query = 5
2 Correct 2 ms 456 KB Output is correct: Maximum length of a query = 6
3 Correct 3 ms 456 KB Output is correct: Maximum length of a query = 5
4 Correct 2 ms 456 KB Output is correct: Maximum length of a query = 5
5 Correct 2 ms 456 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 480 KB Output is correct: Maximum length of a query = 83
2 Correct 11 ms 480 KB Output is correct: Maximum length of a query = 90
3 Correct 11 ms 480 KB Output is correct: Maximum length of a query = 96
4 Correct 8 ms 524 KB Output is correct: Maximum length of a query = 77
5 Correct 11 ms 524 KB Output is correct: Maximum length of a query = 95
6 Correct 7 ms 568 KB Output is correct: Maximum length of a query = 87
7 Correct 8 ms 568 KB Output is correct: Maximum length of a query = 97
8 Correct 14 ms 568 KB Output is correct: Maximum length of a query = 83
9 Correct 11 ms 568 KB Output is correct: Maximum length of a query = 101
10 Correct 13 ms 568 KB Output is correct: Maximum length of a query = 100
11 Correct 11 ms 568 KB Output is correct: Maximum length of a query = 96
12 Correct 12 ms 568 KB Output is correct: Maximum length of a query = 100
13 Correct 14 ms 568 KB Output is correct: Maximum length of a query = 101