Submission #963368

# Submission time Handle Problem Language Result Execution time Memory
963368 2024-04-14T22:00:11 Z biank Hidden Sequence (info1cup18_hidden) C++14
100 / 100
5 ms 1460 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

#define sz(x) int(x.size())

int query(int k, int a, int b) {
    vector<int> s(a, k);
    while (b--) s.push_back(k ^ 1);
    return k ^ 1 ^ isSubsequence(s);
}

vector<int> findSequence(int N) {
    vector<int> s0, s1;
    int n = 0, k = -1;
    while (true) {
        s0.push_back(0);
        if (!isSubsequence(s0)) {
            k = 0;
            break;
        }
        s1.push_back(1);
        if (!isSubsequence(s1)) {
            k = 1;
            break;
        }
        n++;
    }
    int m = N - n;
    vector<int> ans;
    int i = 0, j = 0;
    while (i < n && j < m) {
        int x = -1;
        if (i + m - j < j + n - i) {
            x = query(k, i + 1, m - j);
        } else {
            x = query(k ^ 1, j + 1, n - i);
        }
        if (x == k) i++;
        else j++;
        ans.push_back(x);
    }
    while (i < n) ans.push_back(k), i++;
    while (j < m) ans.push_back(k ^ 1), j++;
    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 1 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 1 ms 596 KB Output is correct: Maximum length of a query = 5
4 Correct 1 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 3 ms 692 KB Output is correct: Maximum length of a query = 83
2 Correct 4 ms 944 KB Output is correct: Maximum length of a query = 90
3 Correct 5 ms 1460 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 5 ms 700 KB Output is correct: Maximum length of a query = 95
6 Correct 3 ms 600 KB Output is correct: Maximum length of a query = 87
7 Correct 3 ms 692 KB Output is correct: Maximum length of a query = 97
8 Correct 3 ms 692 KB Output is correct: Maximum length of a query = 83
9 Correct 4 ms 692 KB Output is correct: Maximum length of a query = 101
10 Correct 4 ms 692 KB Output is correct: Maximum length of a query = 100
11 Correct 4 ms 452 KB Output is correct: Maximum length of a query = 96
12 Correct 3 ms 436 KB Output is correct: Maximum length of a query = 100
13 Correct 4 ms 692 KB Output is correct: Maximum length of a query = 101