Submission #624331

# Submission time Handle Problem Language Result Execution time Memory
624331 2022-08-07T20:23:27 Z as111 Carnival (CEOI14_carnival) C++14
0 / 100
5 ms 464 KB
#include <iostream>
#include <vector>
#include <string>

#define MAXN 150

using namespace std;
vector<int> pos;
int cost[MAXN + 2]; //# costumes for each and the next
int ID[MAXN + 2]; // id of costume
int main() {
	int N;
	cin >> N;
	for (int i = 1; i < N; i++) {
		cout << N - i + 1;
		for (int j = i; j <= N; j++) {
			cout << " " << j;
		}
		cout << endl;
		cin >> (cost[i]);
	}
	int total = 0;
	for (int i = 1; i <= N; i++) {
		if (cost[i] != cost[i + 1]) { // diff costume added
			total++;
			ID[i] = total;
			pos.push_back(i);
		}
	}
	for (int i = 1; i <= N; i++) if (!ID[i]) {
		while (pos[0] < i) pos.erase(pos.begin());
		int l = 0, r = pos.size(), a = pos.size();
		while (l + 1 < r) {
			int m = (l + r) / 2;
			int s = pos.size() - m + 1;
			printf("%d", s);
			for (int i = m; i < pos.size(); i++) printf(" %d", pos[i]);
			printf(" %d\n", i); fflush(stdout);

			int c; scanf("%d", &c);
			if (c == s) r = m;
			else l = m;
		}
		ID[i] = ID[pos[l]];
	}
	cout << 0;
	for (int i = 1; i <= N; i++) {
		cout << " " << ID[i];
	}
	cout << endl;
	return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for (int i = m; i < pos.size(); i++) printf(" %d", pos[i]);
      |                    ~~^~~~~~~~~~~~
carnival.cpp:32:30: warning: unused variable 'a' [-Wunused-variable]
   32 |   int l = 0, r = pos.size(), a = pos.size();
      |                              ^
carnival.cpp:40:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    int c; scanf("%d", &c);
      |           ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 424 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -