Submission #923206

# Submission time Handle Problem Language Result Execution time Memory
923206 2024-02-06T20:51:45 Z Ianis Hidden Sequence (info1cup18_hidden) C++17
100 / 100
2 ms 856 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;

#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()

vector<int> operator+(vector<int> dest, const vector<int> &src) {
   for (auto &it : src)
      dest.push_back(it);
   return dest;
}

vector<int> rev(vector<int> v) {
   reverse(all(v));
   return v;
}

bool flipped;
int cnt[2], used[2];

vector<int> findSequence(int n) {
   vector<int> pref, suff;

   if (isSubsequence(vector(n / 2 + 1, 0)))
      flipped = true;

   for (int i = n / 2; i >= 1; i--) {
      if (isSubsequence(vector<int>(i, flipped))) {
         cnt[flipped] = i;
         break;
      }
   }
   cnt[!flipped] = n - cnt[flipped];
   
   vector<int> ans;

   while (int(ans.size()) < n) {
      vector<int> s;
      if (used[0] + cnt[1] - used[1] < used[1] + cnt[0] - used[0]) {
         s = vector<int>(used[0] + 1, 0) + vector<int>(cnt[1] - used[1], 1);
         if (isSubsequence(s)) ans.push_back(0);
         else ans.push_back(1);
      } else {
         s = vector<int>(used[1] + 1, 1) + vector<int>(cnt[0] - used[0], 0);
         if (isSubsequence(s)) ans.push_back(1);
         else ans.push_back(0);
      }
      used[ans.back()]++;
   }

   return ans;
}

Compilation message

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 5
2 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 6
3 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 5
4 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 5
5 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 4
# Verdict Execution time Memory Grader output
1 Correct 2 ms 440 KB Output is correct: Maximum length of a query = 83
2 Correct 2 ms 432 KB Output is correct: Maximum length of a query = 90
3 Correct 2 ms 432 KB Output is correct: Maximum length of a query = 96
4 Correct 2 ms 692 KB Output is correct: Maximum length of a query = 77
5 Correct 2 ms 856 KB Output is correct: Maximum length of a query = 95
6 Correct 2 ms 696 KB Output is correct: Maximum length of a query = 87
7 Correct 2 ms 444 KB Output is correct: Maximum length of a query = 97
8 Correct 2 ms 596 KB Output is correct: Maximum length of a query = 83
9 Correct 2 ms 436 KB Output is correct: Maximum length of a query = 101
10 Correct 2 ms 692 KB Output is correct: Maximum length of a query = 100
11 Correct 2 ms 436 KB Output is correct: Maximum length of a query = 96
12 Correct 2 ms 696 KB Output is correct: Maximum length of a query = 100
13 Correct 2 ms 432 KB Output is correct: Maximum length of a query = 101