Submission #1142883

#TimeUsernameProblemLanguageResultExecution timeMemory
1142883JelalTkmHidden Sequence (info1cup18_hidden)C++20
0 / 100
2 ms416 KiB
#include <bits/stdc++.h>
#include "grader.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

// #define int long long int

// const int N = 1e3 + 100;
// const int md = 1e9 + 7;
// const int INF = 1e18;

vector<int> findSequence(int n) {
  int m = 0;
  vector<int> v;
  int cnt = 0;
  for (int i = 0; i < ((n + 1) >> 1); i++) {
    v.push_back(0);
    if (isSubsequence(v))
      cnt++;
    else break;
  }
  v = {};
  int cnt1 = 0;
  for (int i = 0; i < ((n + 1) >> 1); i++) {
    v.push_back(1);
    if (isSubsequence(v))
      cnt1++;
    else break;
  }
  int c0, c0_ = 0, c1, c1_ = 0;
  if (cnt != ((n + 1) >> 1)) {
    c0 = cnt;
    c1 = n - cnt;
  } else {
    c0 = n - cnt1;
    c1 = cnt1;
  }
  vector<int> ans;
  int og = (n >> 1) + 1;
  v = {};
  for (int i = 0; i < n; i++) {
    if (min(c0_ + 1, c0) + (c1 - c1_) <= og) {
      v = {};
      for (int i = 0; i < min(c0_ + 1, c0); i++)
        v.push_back(0);
      for (int i = 0; i < (c1 - c1_); i++)
        v.push_back(1);

      if (isSubsequence(v)) {
        ans.push_back(0);
        c0_++;
      } else {
        ans.push_back(1);
        c1_++;
      }
    } else {
      v = {};
      for (int i = 0; i < min(c1_ + 1, c1); i++)
        v.push_back(1);
      for (int i = 0; i < (c0 - c0_); i++)
        v.push_back(0);

      if (isSubsequence(v)) {
        ans.push_back(1);
        c1_++;
      } else {
        ans.push_back(0);
        c0_++;
      }
    }
  }

  return ans;
}

// int32_t main(int32_t argc, char *argv[]) {
//   ios::sync_with_stdio(false);
//   cin.tie(nullptr);

//   int T = 1;
//   // cin >> T;
//   while (T--) {

//   }
//   return 0;
// }

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...