Submission #979053

# Submission time Handle Problem Language Result Execution time Memory
979053 2024-05-10T07:10:14 Z PenguinsAreCute Hidden Sequence (info1cup18_hidden) C++17
100 / 100
4 ms 692 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
namespace {int zeroes, n;}
bool sth(int k, int l) {
    // k, ones-l
    vector<int> v;
    if(k+(n-zeroes-l)<=(n/2)) {
        for(int i=k+1;i--;) v.push_back(0);
        for(int i=n-zeroes-l;i--;) v.push_back(1);
        return isSubsequence(v);
    } else {
        for(int i=l+1;i--;) v.push_back(1);
        for(int i=zeroes-k;i--;) v.push_back(0);
        return !isSubsequence(v);
    }
}
vector<int> findSequence (int N) {
    n = N;
    vector<int> v((N/2)+1,0);
    if(isSubsequence(v)) {
        zeroes = N; v.clear();
        for(int i=1;i<=(N/2);i++) {v.push_back(1); if(isSubsequence(v)) zeroes = N - i;}
    } else {
        zeroes = 0; v.clear();
        for(int i=1;i<=(N/2);i++) {v.push_back(0); if(isSubsequence(v)) zeroes = i;}
    }
    vector<int> ans; int l = 0, r = 0;
    for(int i=0;i<N;i++) {
        if(sth(l,r)) {
            ans.push_back(0);
            l++;
        } else {
            ans.push_back(1);
            r++;
        }
    }
    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 1 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 1 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 3 ms 684 KB Output is correct: Maximum length of a query = 90
3 Correct 3 ms 432 KB Output is correct: Maximum length of a query = 96
4 Correct 3 ms 688 KB Output is correct: Maximum length of a query = 77
5 Correct 3 ms 432 KB Output is correct: Maximum length of a query = 95
6 Correct 2 ms 436 KB Output is correct: Maximum length of a query = 87
7 Correct 3 ms 436 KB Output is correct: Maximum length of a query = 97
8 Correct 2 ms 436 KB Output is correct: Maximum length of a query = 83
9 Correct 3 ms 436 KB Output is correct: Maximum length of a query = 101
10 Correct 4 ms 432 KB Output is correct: Maximum length of a query = 100
11 Correct 3 ms 436 KB Output is correct: Maximum length of a query = 96
12 Correct 3 ms 692 KB Output is correct: Maximum length of a query = 100
13 Correct 3 ms 440 KB Output is correct: Maximum length of a query = 101