답안 #734549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734549 2023-05-02T15:39:42 Z keta_tsimakuridze Hidden Sequence (info1cup18_hidden) C++14
100 / 100
7 ms 304 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;

vector < int > findSequence (int n)
{
    int x = 0; // naklebjer romelic gvxdeba
    vector<int> v;
    for(int i = 1; i <= (n / 2) + 1; i++) v.push_back(x);
    if(isSubsequence(v)) x = 1;
    int cx = 0;
    v.clear();
    for(int i = 1; i <= (n / 2) + 1; i++) {
        v.push_back(x);
        if(!isSubsequence(v)) {
            cx = i - 1; break;
        }
    }
    int l = 0;
    vector<int> ans;
    for(int i = 1; i <= cx; ) {
        if(l == n - cx) {
            ++i;
            ans.push_back(x);
            continue;
        }
        v.clear();
        if(i + n - cx - l <= n / 2 + 1) {
            for(int j = 1; j <= i; j++) v.push_back(x);
            for(int j = 1; j <= n - cx - l; j++) v.push_back(!x);
            if(isSubsequence(v)) ++i, ans.push_back(x);
            else ans.push_back(!x), ++l;
        } else {
            for(int j = 1; j <= l +1; j++) v.push_back(!x);
            for(int j = 1; j <= cx - i + 1; j++) v.push_back(x);
            if(!isSubsequence(v)) ++i, ans.push_back(x);
            else ans.push_back(!x), ++l;
        }
    }
    while(l < n - cx) ++l, ans.push_back(!x);
    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++)
      |                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 220 KB Output is correct: Maximum length of a query = 5
2 Correct 1 ms 208 KB Output is correct: Maximum length of a query = 6
3 Correct 1 ms 208 KB Output is correct: Maximum length of a query = 5
4 Correct 1 ms 208 KB Output is correct: Maximum length of a query = 5
5 Correct 1 ms 208 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct: Maximum length of a query = 83
2 Correct 5 ms 304 KB Output is correct: Maximum length of a query = 90
3 Correct 5 ms 208 KB Output is correct: Maximum length of a query = 96
4 Correct 3 ms 208 KB Output is correct: Maximum length of a query = 77
5 Correct 5 ms 208 KB Output is correct: Maximum length of a query = 95
6 Correct 4 ms 208 KB Output is correct: Maximum length of a query = 87
7 Correct 5 ms 208 KB Output is correct: Maximum length of a query = 97
8 Correct 4 ms 208 KB Output is correct: Maximum length of a query = 83
9 Correct 3 ms 296 KB Output is correct: Maximum length of a query = 101
10 Correct 5 ms 208 KB Output is correct: Maximum length of a query = 100
11 Correct 4 ms 300 KB Output is correct: Maximum length of a query = 96
12 Correct 4 ms 208 KB Output is correct: Maximum length of a query = 100
13 Correct 7 ms 208 KB Output is correct: Maximum length of a query = 101