Submission #381812

# Submission time Handle Problem Language Result Execution time Memory
381812 2021-03-26T01:39:16 Z zoooma13 Hidden Sequence (info1cup18_hidden) C++14
59 / 100
10 ms 492 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector <int> findSequence(int N){
    int C = isSubsequence(vector<int>(N/2+1 ,0)) ,cnt = 1;
    while(isSubsequence(vector<int>(cnt ,C)))
        cnt++;
    if(--cnt == 0)
        return vector <int>(N ,!C);

    vector <int> pos;
    for(int i=cnt; i>=0; i--){
        vector <int> q(cnt ,C);
        q.insert(q.begin()+i ,!C);
        if(isSubsequence(q))
            pos.push_back(i);
    }

    int rem = N - cnt;
    vector <int> dis(pos.size() ,-1);
    for(int i=0; i<pos.size(); i++){
        vector <int> q(cnt ,C);
        for(int l = 1; q.size() <= 3*N/4; l++){
            q.insert(q.begin()+pos[i] ,!C);
            if(!isSubsequence(q)){
                dis[i] = l-1;
                rem -= l-1;
                break;
            }
        }
    }

    if(rem)
        *find(dis.begin() ,dis.end() ,-1) = rem;

    vector <int> ans(cnt ,C);
    for(int i=0; i<pos.size(); i++)
    while(dis[i]-- > 0) ans.insert(ans.begin()+pos[i] ,!C);
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0; i<pos.size(); i++){
      |                  ~^~~~~~~~~~~
hidden.cpp:24:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |         for(int l = 1; q.size() <= 3*N/4; l++){
      |                        ~~~~~~~~~^~~~~~~~
hidden.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0; i<pos.size(); i++)
      |                  ~^~~~~~~~~~~
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 Partially correct 1 ms 364 KB Output is partially correct: Maximum length of a query = 7
2 Partially correct 1 ms 364 KB Output is partially correct: Maximum length of a query = 8
3 Partially correct 1 ms 364 KB Output is partially correct: Maximum length of a query = 7
4 Partially correct 1 ms 364 KB Output is partially correct: Maximum length of a query = 7
5 Partially correct 1 ms 364 KB Output is partially correct: Maximum length of a query = 6
# Verdict Execution time Memory Grader output
1 Partially correct 9 ms 364 KB Output is partially correct: Maximum length of a query = 86
2 Partially correct 8 ms 364 KB Output is partially correct: Maximum length of a query = 92
3 Partially correct 8 ms 364 KB Output is partially correct: Maximum length of a query = 102
4 Partially correct 6 ms 364 KB Output is partially correct: Maximum length of a query = 87
5 Partially correct 8 ms 384 KB Output is partially correct: Maximum length of a query = 103
6 Partially correct 6 ms 364 KB Output is partially correct: Maximum length of a query = 130
7 Partially correct 7 ms 364 KB Output is partially correct: Maximum length of a query = 145
8 Partially correct 4 ms 376 KB Output is partially correct: Maximum length of a query = 124
9 Partially correct 7 ms 492 KB Output is partially correct: Maximum length of a query = 126
10 Partially correct 7 ms 364 KB Output is partially correct: Maximum length of a query = 125
11 Partially correct 10 ms 364 KB Output is partially correct: Maximum length of a query = 97
12 Partially correct 7 ms 364 KB Output is partially correct: Maximum length of a query = 150
13 Partially correct 7 ms 364 KB Output is partially correct: Maximum length of a query = 107