답안 #153253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153253 2019-09-13T05:21:49 Z AlexLuchianov 사육제 (CEOI14_carnival) C++14
0 / 100
2 ms 380 KB
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

#define ll long long
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 150;
vector<int> dif;
vector<int> sol;

bool test(int st, int val){
  cout << st + 1 << " ";
  for(int i = 1; i <= st; i++)
    cout << dif[i] << " ";
  cout << val;
  cout << flush;
  int ans;
  cin >> ans;
  return (ans == st);
}

int binarysearch(int from, int to, int val){
  if(from < to){
    int mid = (from + to) / 2;
    if(test(mid, val) == 1)
      return binarysearch(from, mid, val);
    else
      return binarysearch(mid + 1, to, val);
  } else
    return from;
}

int solve(int val){
  cout << dif.size() << " ";
  for(int i = 1;i < dif.size(); i++)
    cout << dif[i] << " ";
  cout << val;
  cout << flush;
  int sol;
  cin >> sol;
  if(sol == dif.size())
    return dif.size();
  else{
    return binarysearch(0, dif.size() - 1, val);
  }
}

int main()
{
  dif.push_back(0);
  int n;
  cin >> n;
  dif.push_back(1);
  sol.push_back(1);
  for(int i = 2;i <= n; i++){
    int type = solve(i);
    sol.push_back(type);
    if(dif.size() <= type)
      dif.push_back(i);
  }
  cout << 0 << " ";
  for(int i = 0; i < n; i++)
    cout << sol[i] << " ";

  return 0;
}

Compilation message

carnival.cpp: In function 'int solve(int)':
carnival.cpp:39:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 1;i < dif.size(); i++)
                 ~~^~~~~~~~~~~~
carnival.cpp:45:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(sol == dif.size())
      ~~~~^~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:62:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(dif.size() <= type)
        ~~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 252 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 380 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -