Submission #95348

# Submission time Handle Problem Language Result Execution time Memory
95348 2019-01-30T14:27:09 Z dalgerok Hidden Sequence (info1cup18_hidden) C++14
0 / 100
6 ms 296 KB
#include "grader.h"
#include<bits/stdc++.h>
using namespace std;




vector < int > findSequence(int N){
    vector < int > ans(N, 0), v0, v1;
    int kol0 = 0, kol1 = 0, cnt0 = 0, cnt1 = 1;
    for(int i = 0; i < N; i++){
        v0.push_back(0);
        v1.push_back(1);
        if(isSubsequence(v0) == false){
            kol0 = i;
            kol1 = N - kol0;
            break;
        }
        if(isSubsequence(v1) == false){
            kol1 = i;
            kol0 = N - kol1;
            break;
        }
    }
    for(int i = 0; i < N; i++){
        vector < int > vec;
        if(cnt0 + 1 + kol1 - cnt1 <= N / 2 + 1){
            for(int j = 1; j <= cnt0 + 1; j++){
                vec.push_back(0);
            }
            for(int j = 1; j <= kol1 - cnt1; j++){
                vec.push_back(1);
            }
            if(isSubsequence(vec) == true){
                cnt0 += 1;
                ans[i] = 0;
            }
            else{
                cnt1 += 1;
                ans[i] = 1;
            }
        }
        else{
            for(int j = 1; j <= cnt1 + 1; j++){
                vec.push_back(1);
            }
            for(int j = 1; j <= kol0 - cnt0; j++){
                vec.push_back(0);
            }
            if(isSubsequence(vec) == true){
                cnt1 += 1;
                ans[i] = 1;
            }
            else{
                cnt0 += 1;
                ans[i] = 0;
            }
        }
    }
    return ans;
}

Compilation message

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 2 ms 296 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 248 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -