답안 #52197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52197 2018-06-24T18:07:40 Z zadrga 사육제 (CEOI14_carnival) C++14
100 / 100
10 ms 580 KB
#include <bits/stdc++.h>
  
using namespace std;
  
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF (1LL << 55)
#define maxn 155
 
typedef long long ll;
typedef pair<int, int> pii;

int val[maxn];
vector<int> v;

int ask(int l, int d, int x){
	vector<int> cur;
	for(int i = l; i <= d; i++)
		cur.pb(v[i]);

	cur.pb(x);

	cout << cur.size();
	for(int i : cur)
		cout << " " << i;

	cout << endl;

	int ret;
	cin >> ret;
	return ret;
}

  
int main(){
	int n, cnt = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int num = ask(0, v.size() - 1, i);
		if(num == v.size() + 1){
			v.pb(i);
			val[i] = ++cnt;
			continue;
		}

		int l = 0, d = v.size() - 1, mid;
		while(l <= d){
			mid = (l + d) / 2;
			num = ask(l, mid, i);

			if(num == 1){
				val[i] = val[v[l]];
				break;
			}

			if(num == (mid - l + 1 + 1))
				l = mid + 1;

			else
				d = mid;
		}
	}

	cout << "0";
	for(int i = 1; i <= n; i++)
		cout << " " << val[i];

	cout << endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:42:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(num == v.size() + 1){
      ~~~~^~~~~~~~~~~~~~~
carnival.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 248 KB Output is correct
2 Correct 8 ms 308 KB Output is correct
3 Correct 7 ms 392 KB Output is correct
4 Correct 4 ms 396 KB Output is correct
5 Correct 5 ms 396 KB Output is correct
6 Correct 4 ms 416 KB Output is correct
7 Correct 7 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 416 KB Output is correct
2 Correct 7 ms 416 KB Output is correct
3 Correct 6 ms 492 KB Output is correct
4 Correct 6 ms 492 KB Output is correct
5 Correct 6 ms 492 KB Output is correct
6 Correct 7 ms 524 KB Output is correct
7 Correct 7 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 580 KB Output is correct
2 Correct 6 ms 580 KB Output is correct
3 Correct 5 ms 580 KB Output is correct
4 Correct 5 ms 580 KB Output is correct
5 Correct 7 ms 580 KB Output is correct
6 Correct 7 ms 580 KB Output is correct
7 Correct 7 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 580 KB Output is correct
2 Correct 9 ms 580 KB Output is correct
3 Correct 6 ms 580 KB Output is correct
4 Correct 7 ms 580 KB Output is correct
5 Correct 7 ms 580 KB Output is correct
6 Correct 7 ms 580 KB Output is correct
7 Correct 10 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 580 KB Output is correct
2 Correct 6 ms 580 KB Output is correct
3 Correct 7 ms 580 KB Output is correct
4 Correct 7 ms 580 KB Output is correct
5 Correct 5 ms 580 KB Output is correct
6 Correct 4 ms 580 KB Output is correct
7 Correct 4 ms 580 KB Output is correct