답안 #1060339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060339 2024-08-15T13:08:08 Z pera Hidden Sequence (info1cup18_hidden) C++17
100 / 100
4 ms 600 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> findSequence(int N){
   vector<int> ans , X , e(2);
   for(int i = 1;i <= N / 2 + 1;i ++){
      X.emplace_back(1);
      if(isSubsequence(X)){
         e[1] = i;
         e[0] = N - i;
      }
   }
   if(e[1] == N / 2 + 1){
      vector<int>().swap(X);
      for(int i = 1;i <= N / 2 + 1;i ++){
         X.emplace_back(0);
         if(isSubsequence(X)){
            e[0] = i;
            e[1] = N - i;
         }
      }
   }
   vector<int> o(2);
   auto Get = [&](int x , int y , int z){
      vector<int> v;
      for(int i = 1;i <= x + y;i ++){
         v.push_back(z ^ (i > x));
      } 
      return v;
   };
   auto is_Zero = [&](){
      if(o[0] + (e[1] - o[1]) + 1 <= N / 2 + 1){
         return isSubsequence(Get(o[0] + 1 , e[1] - o[1] , 0));
      }else{
         return !isSubsequence(Get(o[1] + 1 , e[0] - o[0] , 1));
      }
   };
   for(int i = 1;i <= N;i ++){
      ans.emplace_back(!is_Zero());
      o[ans.back()]++;
   }
   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 0 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 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 0 ms 344 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 83
2 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 90
3 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 96
4 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 77
5 Correct 3 ms 344 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 344 KB Output is correct: Maximum length of a query = 97
8 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 83
9 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 101
10 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 100
11 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 96
12 Correct 4 ms 344 KB Output is correct: Maximum length of a query = 100
13 Correct 3 ms 600 KB Output is correct: Maximum length of a query = 101