답안 #99562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99562 2019-03-05T07:11:34 Z tushar_2658 Hidden Sequence (info1cup18_hidden) C++14
20 / 100
13 ms 560 KB
#include<bits/stdc++.h>

using namespace std;

bool isSubsequence(vector<int> v);

bool issubsequence (vector < int > v, vector<int> theRealAnswer)
{
    int i = 0;
    for (auto it : v)
    {
        while (i < theRealAnswer.size () && it != theRealAnswer[i]) i ++;
        if (i == theRealAnswer.size ()) return 0;
        i ++;
    }
    return 1;
}

vector < int > findSequence (int N){
    int mask = 0;
    for(; mask < (1 << N); mask++){
        vector<int> vec;
        for(int i=0; i<N; i++){
            if(mask & (1 << i))vec.emplace_back(1);
            else vec.emplace_back(0);
        }
        int flag = 1;
        int x = N/2 + 1;
        for(int mask2 = 0; mask2 < (1 << x); mask2++){
            vector<int> v;
            for(int i=0; i<x; i++){
                if(mask2 & (1 << i))v.emplace_back(1);
                else v.emplace_back(0);
            }
            if(issubsequence(v, vec) != isSubsequence(v)){
                flag = 0;
                break;
            }
        }
        if(flag){
            return vec;
        }
    }
}


Compilation message

hidden.cpp: In function 'bool issubsequence(std::vector<int>, std::vector<int>)':
hidden.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (i < theRealAnswer.size () && it != theRealAnswer[i]) i ++;
                ~~^~~~~~~~~~~~~~~~~~~~~~~
hidden.cpp:13:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i == theRealAnswer.size ()) return 0;
             ~~^~~~~~~~~~~~~~~~~~~~~~~~
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
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++)
                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct: Maximum length of a query = 5
2 Correct 4 ms 256 KB Output is correct: Maximum length of a query = 6
3 Correct 5 ms 384 KB Output is correct: Maximum length of a query = 5
4 Correct 13 ms 384 KB Output is correct: Maximum length of a query = 5
5 Correct 3 ms 256 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -