답안 #895330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895330 2023-12-29T18:55:41 Z borisAngelov Hidden Sequence (info1cup18_hidden) C++17
34 / 100
5 ms 976 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;

int countDigits(int digit, int n)
{
    vector<int> v;
    v.push_back(digit);

    int cnt = 1;

    while (cnt <= n)
    {
        if (isSubsequence(v) == false)
        {
            return cnt - 1;
        }

        v.push_back(digit);

        ++cnt;
    }

    return n;
}

vector<int> findSequence(int n)
{
    int cnt0 = countDigits(0, n);
    int cnt1 = n - cnt0;

    vector<int> sequence;

    for (int i = 0; i < n; ++i)
    {
        if (cnt0 == 0)
        {
            sequence.push_back(1);
            continue;
        }

        if (cnt1 == 0)
        {
            sequence.push_back(0);
            continue;
        }

        vector<int> curr;

        for (int j = 0; j < sequence.size(); ++j)
        {
            curr.push_back(sequence[j]);
        }

        curr.push_back(0);

        for (int j = 1; j <= cnt1; ++j)
        {
            curr.push_back(1);
        }


        if (isSubsequence(curr) == true)
        {
            sequence.push_back(0);
            --cnt0;
        }
        else
        {
            sequence.push_back(1);
            --cnt1;
        }
    }

    return sequence;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:51:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for (int j = 0; j < sequence.size(); ++j)
      |                         ~~^~~~~~~~~~~~~~~~~
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 8
2 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 9
3 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 8
4 Partially correct 1 ms 600 KB Output is partially correct: Maximum length of a query = 9
5 Partially correct 1 ms 344 KB Output is partially correct: Maximum length of a query = 7
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3 ms 440 KB Output is partially correct: Maximum length of a query = 165
2 Partially correct 4 ms 700 KB Output is partially correct: Maximum length of a query = 178
3 Partially correct 5 ms 948 KB Output is partially correct: Maximum length of a query = 190
4 Partially correct 3 ms 688 KB Output is partially correct: Maximum length of a query = 153
5 Partially correct 4 ms 696 KB Output is partially correct: Maximum length of a query = 187
6 Partially correct 3 ms 696 KB Output is partially correct: Maximum length of a query = 160
7 Partially correct 3 ms 700 KB Output is partially correct: Maximum length of a query = 183
8 Partially correct 3 ms 444 KB Output is partially correct: Maximum length of a query = 163
9 Partially correct 4 ms 452 KB Output is partially correct: Maximum length of a query = 199
10 Partially correct 4 ms 688 KB Output is partially correct: Maximum length of a query = 195
11 Partially correct 3 ms 944 KB Output is partially correct: Maximum length of a query = 190
12 Partially correct 3 ms 440 KB Output is partially correct: Maximum length of a query = 151
13 Partially correct 4 ms 976 KB Output is partially correct: Maximum length of a query = 200