답안 #105164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105164 2019-04-10T18:54:52 Z stefdasca Hidden Sequence (info1cup18_hidden) C++14
100 / 100
11 ms 440 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int>findSequence(int N)
{
    vector<int> ans (N, 0);
    vector<int> qu;
    vector<int> qu1;
    vector<int> qu2;
    int nr0 = 0, nr1 = 0;
    while(1)
    {
        qu.push_back(0);
        qu1.push_back(1);
        if(isSubsequence(qu))
            ++nr0;
        else
        {
            nr1 = N - nr0;
            break;
        }
        if(isSubsequence(qu1))
            ++nr1;
        else
        {
            nr0 = N - nr1;
            break;
        }
    }
    int cntsf0 = nr0, cntsf1 = nr1;
    for(int i = 0; i < N; ++i)
    {
        if(cntsf0 == 0)
        {
            for(int j = i; j < N; ++j)
                ans[j] = 1;
            break;
        }
        if(cntsf1 == 0)
        {
            for(int j = i; j < N; ++j)
                ans[j] = 0;
            break;
        }
        qu.clear();
        qu2.clear();
        for(int j = 0; j < nr0 - cntsf0 + 1; ++j)
            qu.push_back(0);
        for(int j = 0; j < cntsf1; ++j)
            qu.push_back(1);
        for(int j = 0; j < nr1 - cntsf1 + 1; ++j)
            qu2.push_back(1);
        for(int j = 0; j < cntsf0; ++j)
            qu2.push_back(0);
        if(qu.size() <= (N/2+1))
        {
            if(isSubsequence(qu))
                ans[i] = 0, --cntsf0;
            else
                ans[i] = 1, --cntsf1;
        }
        else
        {
            if(isSubsequence(qu2))
                ans[i] = 1, --cntsf1;
            else
                ans[i] = 0, --cntsf0;
        }

    }
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:55:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(qu.size() <= (N/2+1))
            ~~~~~~~~~~^~~~~~~~~~
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 384 KB Output is correct: Maximum length of a query = 5
2 Correct 2 ms 256 KB Output is correct: Maximum length of a query = 6
3 Correct 2 ms 384 KB Output is correct: Maximum length of a query = 5
4 Correct 2 ms 256 KB Output is correct: Maximum length of a query = 5
5 Correct 2 ms 256 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct: Maximum length of a query = 83
2 Correct 6 ms 384 KB Output is correct: Maximum length of a query = 90
3 Correct 6 ms 256 KB Output is correct: Maximum length of a query = 96
4 Correct 8 ms 256 KB Output is correct: Maximum length of a query = 77
5 Correct 5 ms 440 KB Output is correct: Maximum length of a query = 95
6 Correct 7 ms 256 KB Output is correct: Maximum length of a query = 87
7 Correct 11 ms 256 KB Output is correct: Maximum length of a query = 97
8 Correct 10 ms 412 KB Output is correct: Maximum length of a query = 83
9 Correct 7 ms 320 KB Output is correct: Maximum length of a query = 101
10 Correct 6 ms 404 KB Output is correct: Maximum length of a query = 100
11 Correct 10 ms 256 KB Output is correct: Maximum length of a query = 96
12 Correct 7 ms 408 KB Output is correct: Maximum length of a query = 100
13 Correct 8 ms 384 KB Output is correct: Maximum length of a query = 101