Submission #105157

# Submission time Handle Problem Language Result Execution time Memory
105157 2019-04-10T18:11:50 Z stefdasca Hidden Sequence (info1cup18_hidden) C++14
0 / 100
6 ms 256 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;
    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 = 0, cntsf1 = 0;
    for(int i = 0; i < N; ++i)
    {
        qu.clear();
        int pp = i;
        while(pp && ans[pp-1] == ans[i-1])
            qu.push_back(ans[i-1]), --pp;
        if(i-1 && ans[i-1] == 0)
        {
            if(cntsf0 - qu.size() < cntsf1)
                for(int j = 0; j < cntsf0 - qu.size(); ++j)
                    qu.push_back(0);
            else
                for(int j = 0; j < cntsf1; ++j)
                    qu.push_back(1);
        }
        else
            if(i-1 && ans[i-1] == 1)
            {
                if(cntsf1 - qu.size() < cntsf0)
                    for(int j = 0; j < cntsf1 - qu.size(); ++j)
                        qu.push_back(1);
                else
                    for(int j = 0; j < cntsf0; ++j)
                        qu.push_back(0);
            }
        reverse(qu.begin(), qu.end());
        if(nr0 <= nr1)
        {
            qu.push_back(1);
            for(int j = 0; j < nr0; ++j)
                qu.push_back(0);
            if(isSubsequence(qu))
                ans[i] = 1, ++cntsf1, --nr1;
            else
                ans[i] = 0, ++cntsf0, --nr0;
        }
        else
        {
            qu.push_back(0);
            for(int j = 0; j < nr1; ++j)
                qu.push_back(1);
            if(isSubsequence(qu))
                ans[i] = 0, ++cntsf0, --nr0;
            else
                ans[i] = 1, ++cntsf1, --nr1;
        }
    }
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:38:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(cntsf0 - qu.size() < cntsf1)
                ~~~~~~~~~~~~~~~~~~~^~~~~~~~
hidden.cpp:39:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j = 0; j < cntsf0 - qu.size(); ++j)
                                ~~^~~~~~~~~~~~~~~~~~~~
hidden.cpp:48:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(cntsf1 - qu.size() < cntsf0)
                    ~~~~~~~~~~~~~~~~~~~^~~~~~~~
hidden.cpp:49:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     for(int j = 0; j < cntsf1 - qu.size(); ++j)
                                    ~~^~~~~~~~~~~~~~~~~~~~
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++)
                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 256 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 256 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -