답안 #72685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72685 2018-08-26T15:02:54 Z memikakizaki Hidden Sequence (info1cup18_hidden) C++14
100 / 100
13 ms 628 KB
#include "grader.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> findSequence(int n) {
  int cnt_small = 0, small = 0;
  vector<int> tmp;
  while(cnt_small <= n / 2) {
    tmp.push_back(0);
    if(!isSubsequence(tmp))
      break;
    ++cnt_small;
  }
  if(cnt_small == n / 2 + 1) {
    cnt_small = 0;
    tmp.clear();
    small = 1;
    while(cnt_small <= n / 2) {
      tmp.push_back(1);
      if(!isSubsequence(tmp))
        break;
      ++cnt_small;
    }
  }

  int l_larges = 0, r_larges = n - cnt_small;
  vector<int> ans;

  for(int sect = 0; sect <= cnt_small; sect++) {
    bool valid = true;
    while(valid && r_larges) {
      vector<int> query_vec;
      if(cnt_small - sect + l_larges <= sect + r_larges) {
        for(int i = 0; i < l_larges + 1; i++)
          query_vec.push_back(small ^ 1);
        for(int i = 0; i < cnt_small - sect; i++)
          query_vec.push_back(small);
        if(isSubsequence(query_vec)) {
          ans.push_back(small ^ 1);
          ++l_larges;
          --r_larges;
        } else
          valid = false;
      } else {
        for(int i = 0; i < sect + 1; i++)
          query_vec.push_back(small);
        for(int i = 0; i < r_larges; i++)
          query_vec.push_back(small ^ 1);
        if(!isSubsequence(query_vec)) {
          ans.push_back(small ^ 1);
          ++l_larges;
          --r_larges;
        } else
          valid = false;
      }
    }
    if(sect != cnt_small)
      ans.push_back(small);
  }

  return ans;
}

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 252 KB Output is correct: Maximum length of a query = 5
2 Correct 3 ms 436 KB Output is correct: Maximum length of a query = 6
3 Correct 4 ms 496 KB Output is correct: Maximum length of a query = 5
4 Correct 2 ms 496 KB Output is correct: Maximum length of a query = 5
5 Correct 2 ms 496 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 496 KB Output is correct: Maximum length of a query = 83
2 Correct 9 ms 628 KB Output is correct: Maximum length of a query = 90
3 Correct 12 ms 628 KB Output is correct: Maximum length of a query = 96
4 Correct 8 ms 628 KB Output is correct: Maximum length of a query = 77
5 Correct 7 ms 628 KB Output is correct: Maximum length of a query = 95
6 Correct 5 ms 628 KB Output is correct: Maximum length of a query = 87
7 Correct 8 ms 628 KB Output is correct: Maximum length of a query = 97
8 Correct 6 ms 628 KB Output is correct: Maximum length of a query = 83
9 Correct 13 ms 628 KB Output is correct: Maximum length of a query = 101
10 Correct 7 ms 628 KB Output is correct: Maximum length of a query = 100
11 Correct 9 ms 628 KB Output is correct: Maximum length of a query = 96
12 Correct 10 ms 628 KB Output is correct: Maximum length of a query = 100
13 Correct 7 ms 628 KB Output is correct: Maximum length of a query = 101