제출 #1235695

#제출 시각아이디문제언어결과실행 시간메모리
1235695AishaHidden Sequence (info1cup18_hidden)C++20
34 / 100
35 ms420 KiB
#include "bits/stdc++.h"
#include "grader.h"

using namespace std;

vector <int> findSequence(int n) {
    vector <int> ans;
    int cnt0 = 0, cnt1 = 0;
    vector <int> q;
    for (int i = 1; i <= n; i ++) {
        q.push_back(0);
        bool ok = isSubsequence(q);
        if (ok) cnt0 ++;
        else break;
    }

    cnt1 = n - cnt0;

    //cout << cnt0 << ' ' << cnt1 << endl;

    q.clear();
    int x = 1; q.push_back(0);

    while (cnt1 > 0) {
        int k = 0;
        for (int i = 1; i <= cnt1; i ++) {
            q.push_back(1);
          //  for (int j : q) cout << j << ' ';
          //  cout << endl; 
            bool ok = isSubsequence(q);
           // cout << ok << endl;
            if (ok) k ++;
            else break;
        }
        for (int i = 1; i <= cnt1 - k; i ++) ans.push_back(1);
        if (x == cnt0 + 1) break;
        ans.push_back(0);
      //  if (x == cnt0) break;
        x ++;
        q.clear();
        for (int i = 1; i <= x; i ++) q.push_back(0);
        cnt1 = k;
    }    

    while (ans.size() < n) ans.push_back(0);
   // for (int i = x + 1; i <= cnt0; i ++) ans.push_back(0);
    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
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...