제출 #1320791

#제출 시각아이디문제언어결과실행 시간메모리
1320791hoangmc2009Hidden Sequence (info1cup18_hidden)C++17
10 / 100
2 ms400 KiB
#include<bits/stdc++.h>
using namespace std;
#ifndef Graven
#include "grader.h"
#endif
#ifdef Graven
int maxQ=0;
vector<int> theRealAnswer;
bool isSubsequence(const vector<int>& v)
{
    if (v.size()>maxQ) maxQ=v.size();
    for(int i=0,j=0;i<v.size();++i)
    {
        while(j<theRealAnswer.size() and v[i]!=theRealAnswer[j]) ++j;
        if(j==theRealAnswer.size()) return false;
        else ++j;
    }
    return true;
}
#endif
vector<int> findSequence (int N)
{
    if(N<=10)
    {
        for(int i=0;i<(1<<N);++i)
        {
            vector<int> wh;
            for(int j=0;j<N;++j)
                wh.push_back((i>>j)&1);
            if(isSubsequence(wh)) return wh;
        }
    }
    else return vector<int>(N,0);
}
#ifdef Graven
int main()
{
    int n, x;
    scanf ("%d", &n), maxQ = 0;
    for (int i=1; i<=n; i++)
        scanf ("%d", &x), theRealAnswer.push_back(x);
    vector<int> ans=findSequence(n);
    if (ans.size () != theRealAnswer.size ())
    {
        printf ("Different lengths\n");
        for (auto it : ans) printf ("%d ", it);
        printf ("\n");
        return 0;
    }
    for (int i=0;i<ans.size();i++)
    {
        if (ans[i]!=theRealAnswer[i])
        {
            printf("WA position %d\n",i+1);
            for (auto it : ans) printf ("%d ", it);
            printf ("\n");
            return 0;
        }
    }
    printf ("Ok, biggest queried length %d\n", maxQ);
    return 0;
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
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
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...