Submission #847997

# Submission time Handle Problem Language Result Execution time Memory
847997 2023-09-11T00:47:08 Z Charizard2021 Hidden Sequence (info1cup18_hidden) C++17
0 / 100
2 ms 432 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> findSequence(int n){
    vector<int> v1;
    vector<int> v2;
    int idx1 = 0;
    int idx2 = 0;
    while(true){
        v1.push_back(0);
        v2.push_back(1);
        if(isSubsequence(v1)){
            idx1++;
        }
        else{
            idx2 = n - idx1;
            break;
        }
        if(isSubsequence(v2)){
            idx2++;
        }
        else{
            idx1 = n - idx2;
            break;
        }
    }
    int val1 = idx1;
    int val2 = idx2;
    vector<int> ans(n, 0);
    for(int i = 0; i < n; i++){
        if(val1 == 0){
            for(int j = i; j < n; j++){
                ans[j] = 1;
            }
            break;
        }
        if(val2 == 0){
            for(int j = i; j < n; j++){
                ans[j] = 0;
            }
            break;
        }
        v1.clear();
        v2.clear();
        for(int j = 0;  j < idx1 - val1 + 1; j++){
            v1.push_back(0);
        }
        for(int j = 0; j < val1; j++){
            v1.push_back(1);
        }
        for(int j = 0;  j < idx2 - val2 + 1; j++){
            v2.push_back(1);
        }
        for(int j = 0; j < val2; j++){
            v2.push_back(0);
        }
        if(v1.size() <= (n / 2 + 1)){
            if(isSubsequence(v1)){
                ans[i] = 0;
                val1--;
            }
            else{
                ans[i] = 1;
                val2--;
            }
        }
        else{
            if(isSubsequence(v2)){
                ans[i] = 1;
                val2--;
            }
            else{
                ans[i] = 0;
                val1--;
            }
        }
    }
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:57:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |         if(v1.size() <= (n / 2 + 1)){
      |            ~~~~~~~~~~^~~~~~~~~~~~~~
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 344 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 2 ms 432 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -