Submission #46196

# Submission time Handle Problem Language Result Execution time Memory
46196 2018-04-17T18:56:31 Z ikura355 Carnival (CEOI14_carnival) C++14
100 / 100
15 ms 576 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 150 + 5;
int n;
int c, rep[maxn], com[maxn];
vector<int> p, act;
int ask() {
    printf("%d",act.size());
    for(auto x : act) printf(" %d",x);
    printf("\n");
    fflush(stdout);
    int ret; scanf("%d",&ret);
    return ret;
}
int noey(int l, int r, int x) {
	act.clear();
	for(int i=l;i<=r;i++) act.push_back(p[i]);
	int old = ask();
	act.push_back(x);
	int boy = ask();
	return old == boy;
}
void connect(int x) {
	p.clear();
	for(int i=1;i<=c;i++) p.push_back(rep[i]);
	//1. new component
	if(c==0 || !noey(0,p.size()-1,x)) {
		rep[++c] = x;
		com[x] = c;
		return ;
	}
	//2. connecting
	int l = 0, r = p.size()-1;
	while(l<r) {
		int mid = (l+r)/2;
		if(noey(l,mid,x)) r = mid;
		else l = mid+1;
	}
	com[x] = com[p[l]];
}
int main() {
	scanf("%d",&n);
	for(int x=1;x<=n;x++) connect(x);
	printf("0");
	for(int x=1;x<=n;x++) printf(" %d",com[x]);
	fflush(stdout);
}

Compilation message

carnival.cpp: In function 'int ask()':
carnival.cpp:8:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d",act.size());
                 ~~~~~~~~~~^
carnival.cpp:12:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int ret; scanf("%d",&ret);
              ~~~~~^~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 248 KB Output is correct
2 Correct 13 ms 308 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 6 ms 420 KB Output is correct
5 Correct 9 ms 504 KB Output is correct
6 Correct 4 ms 524 KB Output is correct
7 Correct 11 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 524 KB Output is correct
2 Correct 15 ms 524 KB Output is correct
3 Correct 6 ms 524 KB Output is correct
4 Correct 7 ms 524 KB Output is correct
5 Correct 12 ms 524 KB Output is correct
6 Correct 12 ms 524 KB Output is correct
7 Correct 12 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 524 KB Output is correct
2 Correct 8 ms 524 KB Output is correct
3 Correct 11 ms 524 KB Output is correct
4 Correct 8 ms 572 KB Output is correct
5 Correct 10 ms 572 KB Output is correct
6 Correct 12 ms 572 KB Output is correct
7 Correct 15 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 572 KB Output is correct
2 Correct 6 ms 572 KB Output is correct
3 Correct 7 ms 572 KB Output is correct
4 Correct 7 ms 576 KB Output is correct
5 Correct 13 ms 576 KB Output is correct
6 Correct 9 ms 576 KB Output is correct
7 Correct 12 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 576 KB Output is correct
2 Correct 13 ms 576 KB Output is correct
3 Correct 8 ms 576 KB Output is correct
4 Correct 7 ms 576 KB Output is correct
5 Correct 10 ms 576 KB Output is correct
6 Correct 12 ms 576 KB Output is correct
7 Correct 8 ms 576 KB Output is correct