Submission #347310

# Submission time Handle Problem Language Result Execution time Memory
347310 2021-01-12T14:05:21 Z maomao90 Library (JOI18_library) C++14
0 / 100
1 ms 364 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define pb push_back

void Solve(int n) {
	vector<int> q(n, 1), res(n, -1), done(n, 0);
	int end = -1;
	REP (i, 0, n) {
		q[i] = 0;
		if (Query(q) == 1) {
			end = i;
			break;
		}
		q[i] = 1;
	}
	printf("%d\n", end);
	res[0] = end;
	done[end] = 1;
	REP (i, 1, n) {
		vector<int> useful;
		REP (j, 0, n) if (!done[j]) useful.pb(j);
		int lo = 0, hi = useful.size() - 1, mid;
		while (lo < hi) {
			mid = lo + hi + 1 >> 1;
			REP (j, 0, n) q[j] = 0;
			REP (j, 0, mid) q[useful[j]] = 1;
			q[res[i - 1]] = 1;
			int with = Query(q);
			q[res[i - 1]] = 0;
			int without = Query(q);
			if (with == without) {
				hi = mid - 1;
			} else {
				lo = mid;
			}
		}
		res[i] = useful[hi];
		done[useful[hi]] = 1;
	}
	REP (i, 0, n) res[i]++;
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:27:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |    mid = lo + hi + 1 >> 1;
      |          ~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -