답안 #153255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153255 2019-09-13T05:24:49 Z AlexLuchianov 사육제 (CEOI14_carnival) C++14
100 / 100
11 ms 424 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 << endl;
  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 << endl;
  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] << " ";
  cout << endl;

  return 0;
}

Compilation message

carnival.cpp: In function 'int solve(int)':
carnival.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 1;i < dif.size(); i++)
                 ~~^~~~~~~~~~~~
carnival.cpp:43:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(sol == dif.size())
      ~~~~^~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:60:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(dif.size() <= type)
        ~~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 316 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB Output is correct
2 Correct 10 ms 248 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 276 KB Output is correct
5 Correct 8 ms 248 KB Output is correct
6 Correct 8 ms 380 KB Output is correct
7 Correct 6 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 316 KB Output is correct
2 Correct 8 ms 248 KB Output is correct
3 Correct 11 ms 420 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 9 ms 252 KB Output is correct
6 Correct 8 ms 424 KB Output is correct
7 Correct 10 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 312 KB Output is correct
2 Correct 5 ms 316 KB Output is correct
3 Correct 8 ms 248 KB Output is correct
4 Correct 4 ms 400 KB Output is correct
5 Correct 7 ms 376 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 11 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 6 ms 312 KB Output is correct
3 Correct 8 ms 320 KB Output is correct
4 Correct 10 ms 376 KB Output is correct
5 Correct 9 ms 248 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 6 ms 248 KB Output is correct