Submission #998999

# Submission time Handle Problem Language Result Execution time Memory
998999 2024-06-15T04:07:52 Z Warinchai Hidden Sequence (info1cup18_hidden) C++14
0 / 100
3 ms 344 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;
int ar[205];
vector < int > findSequence (int N)
{
    if(!isSubsequence({0}))return vector<int>(N,1);
    if(!isSubsequence({1}))return vector<int>(N,0);
    int ln=-1;
    int small=0;
    vector<int>ans;
    for(int i=1;i<=(N/2)+1;i++){
        ans.push_back(0);
        if(!isSubsequence(ans)){
            ln=i-1;
            small=0;
            break;
        }
    }
    ans.clear();
    if(ln==-1){
        ln=(N/2);
        for(int i=1;i<=(N/2);i++){
            ans.push_back(1);
            if(!isSubsequence(ans))ln=i-1;
        }
        small=1;
    }
    int big=small^1;
    ans.clear();
    vector<int>spaces;
    for(int i=1;i<ln;i++){
        vector<int>temp;
        for(int j=0;j<i;j++)temp.push_back(small);
        temp.push_back(big);
        for(int j=i;j<ln;j++)temp.push_back(small);
        if(isSubsequence(temp))spaces.push_back(i);
    }
    int toobig=-1;
    int sum=0;
    for(int i=0;i<=spaces.size()+1;i++){
        vector<int>temp;
        int sz=0;
        int check=0;
        while(1){
            sz++;
            if((sz+spaces.size()+1>(N/2)+2)){
                check=1;
                break;
            }
            temp.clear();
            for(int j=0;j<i;j++)temp.push_back(small);
            for(int j=0;j<sz;j++)temp.push_back(big);
            for(int j=i;j<=spaces.size();j++)temp.push_back(small);
            if(!isSubsequence(temp)){
                break;
            }
        }
        if(check){
            toobig=i;
            ar[i]=-1;
        }else{
            ar[i]=sz-1;
            sum+=sz-1;
        }
    }
    //cerr<<"work\n";
    if(toobig!=-1){
        ar[toobig]=N-ln-sum;
    }
    int cur=0;
    /*cerr<<"ar:\n";
    for(int i=0;i<=spaces.size()+1;i++){
        cerr<<ar[i]<<" ";
    }
    cerr<<"\n";*/
    for(int i=0;i<ar[0];i++)ans.push_back(big);
    for(int i=0;i<spaces.size();i++){
        for(;cur<spaces[i];cur++)ans.push_back(small);
        for(int j=0;j<ar[i+1];j++)ans.push_back(big);
    }
    //cerr<<"work\n";
    for(;cur<ln;cur++)ans.push_back(small);
    for(int i=0;i<ar[spaces.size()+1];i++)ans.push_back(big);
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0;i<=spaces.size()+1;i++){
      |                 ~^~~~~~~~~~~~~~~~~
hidden.cpp:48:35: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |             if((sz+spaces.size()+1>(N/2)+2)){
      |                 ~~~~~~~~~~~~~~~~~~^~~~~~~~
hidden.cpp:55:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for(int j=i;j<=spaces.size();j++)temp.push_back(small);
      |                         ~^~~~~~~~~~~~~~~
hidden.cpp:79:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for(int i=0;i<spaces.size();i++){
      |                 ~^~~~~~~~~~~~~~
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++)
      |                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 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 3 ms 344 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -