Submission #1141849

#TimeUsernameProblemLanguageResultExecution timeMemory
1141849MuhammetHidden Sequence (info1cup18_hidden)C++20
15 / 100
1 ms408 KiB
#include "bits/stdc++.h"
#include "grader.h"
// #include "grader.cpp"

using namespace std;

int n;

int f(int x){
    vector <int> v;
    for(int i = n/2+1; i > 0; i--){
        v.clear();
        for(int j = 0; j < i; j++){
            v.push_back(x);
        }
        if(isSubsequence(v)){
            return i;
        }
    }
    return 0;
}

vector <int> findSequence (int N) {
    n = N;
    int a = f(0), b = n-a;
    if(!a) b = f(1), a = n-b;
    int x = 0, y = 1;
    deque <int> d;
    if(b > a) swap(a,b), swap(x,y);
    vector <int> v, ans;
    if(b == 0){
        for(int i = 0; i < a; x++) v.push_back(x);
        return v;
    }
    d.push_back(x);
    for(int i = 0; i < b; i++) d.push_back(y);
    int a1 = 0, b1 = 0;
    while((int)ans.size() < n){
        v.clear();
        for(auto i : d) v.push_back(i);
        if(isSubsequence(v)){
            ans.push_back(x);
            d.push_front(x);
            a1++;
            if(a1 == a){
                while(b1 != b){
                    ans.push_back(y);
                    b1++;
                }
                break;
            }
        }
        else {
            ans.push_back(y);
            d.pop_back();
            b1++;
            if(b1 == b){
                while(a1 != a){
                    ans.push_back(x);
                    a1++;
                }
                break;
            }
        }
    }
    return ans;
}

Compilation message (stderr)

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
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...