제출 #734549

#제출 시각아이디문제언어결과실행 시간메모리
734549keta_tsimakuridzeHidden Sequence (info1cup18_hidden)C++14
100 / 100
7 ms304 KiB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;

vector < int > findSequence (int n)
{
    int x = 0; // naklebjer romelic gvxdeba
    vector<int> v;
    for(int i = 1; i <= (n / 2) + 1; i++) v.push_back(x);
    if(isSubsequence(v)) x = 1;
    int cx = 0;
    v.clear();
    for(int i = 1; i <= (n / 2) + 1; i++) {
        v.push_back(x);
        if(!isSubsequence(v)) {
            cx = i - 1; break;
        }
    }
    int l = 0;
    vector<int> ans;
    for(int i = 1; i <= cx; ) {
        if(l == n - cx) {
            ++i;
            ans.push_back(x);
            continue;
        }
        v.clear();
        if(i + n - cx - l <= n / 2 + 1) {
            for(int j = 1; j <= i; j++) v.push_back(x);
            for(int j = 1; j <= n - cx - l; j++) v.push_back(!x);
            if(isSubsequence(v)) ++i, ans.push_back(x);
            else ans.push_back(!x), ++l;
        } else {
            for(int j = 1; j <= l +1; j++) v.push_back(!x);
            for(int j = 1; j <= cx - i + 1; j++) v.push_back(x);
            if(!isSubsequence(v)) ++i, ans.push_back(x);
            else ans.push_back(!x), ++l;
        }
    }
    while(l < n - cx) ++l, ans.push_back(!x);
    return ans;
}

컴파일 시 표준 에러 (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
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...