Submission #625885

# Submission time Handle Problem Language Result Execution time Memory
625885 2022-08-11T00:52:31 Z as111 Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 304 KB
#include <iostream>
#include <vector>
#include <string>

#define MAXN 150

using namespace std;
vector<int> pos;
int cost[MAXN + 5]; //# costumes for each and the next
int ID[MAXN + 5]; // id of costume
int total;
int main() {
	int N; scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		printf("%d", N - i + 1);
		for (int j = i; j <= N; j++) printf(" %d", j); puts(""); fflush(stdout);
		scanf("%d", cost + i);
	}
	cost[N] = 1;
	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; cin >> 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:16:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   16 |   for (int j = i; j <= N; j++) printf(" %d", j); puts(""); fflush(stdout);
      |   ^~~
carnival.cpp:16:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   16 |   for (int j = i; j <= N; j++) printf(" %d", j); puts(""); fflush(stdout);
      |                                                  ^~~~
carnival.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for (int i = m; i < pos.size(); i++) printf(" %d", pos[i]);
      |                    ~~^~~~~~~~~~~~
carnival.cpp:33:3: warning: unused variable 'a' [-Wunused-variable]
   33 |   a = pos.size();
      |   ^
carnival.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  int N; scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
carnival.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", cost + i);
      |   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 220 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 304 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 3 ms 304 KB Output is correct