Submission #61796

# Submission time Handle Problem Language Result Execution time Memory
61796 2018-07-26T17:59:40 Z kingpig9 Library (JOI18_library) C++11
19 / 100
2000 ms 572 KB
#include <bits/stdc++.h>
#include "library.h"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1010;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N;

vector<int> getmsk (vector<int> v) {
	vector<int> m(N);
	for (int i : v) {
		m[i] = true;
	}
	return m;
}

bool has[MAXN];

int query() {
	return Query(vector<int> (has, has + N));
}

void Solve (int nnn) {
	N = nnn;
	deque<int> dq = {0};
	has[0] = true;

	for (int i = 1; i < N; i++) {
		//find the one adjacent
		vector<int> poss;
		for (int j = 1; j < N; j++) {
			if (!has[j]) {
				poss.push_back(j);
			}
		}

		int val = -1;
		for (int j = 0; j + 1 < poss.size(); j++) {
			int x = poss[j];
			has[x] = true;
			if (query() == 1) {
				val = x;
				break;
			}
			has[x] = false;
		}
		if (val == -1) {
			val = poss.back();
			has[val] = true;
		}

		//which one is it now?
		bool isbck = false;
		if (dq.size() > 1) {
			//maybe it's true!
			if (Query(getmsk(vector<int> {dq.back(), val})) == 1) {
				isbck = true;
			}
		}

		if (isbck) {
			dq.push_back(val);
		} else {
			dq.push_front(val);
		}
	}

	for (int &x : dq) {
		x++;
	}
	Answer(vector<int> (all(dq)));
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j + 1 < poss.size(); j++) {
                   ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 160 ms 248 KB Output is correct
2 Correct 182 ms 436 KB Output is correct
3 Correct 198 ms 496 KB Output is correct
4 Correct 141 ms 496 KB Output is correct
5 Correct 236 ms 496 KB Output is correct
6 Correct 195 ms 496 KB Output is correct
7 Correct 202 ms 524 KB Output is correct
8 Correct 225 ms 524 KB Output is correct
9 Correct 181 ms 524 KB Output is correct
10 Correct 95 ms 524 KB Output is correct
11 Correct 2 ms 524 KB Output is correct
12 Correct 2 ms 524 KB Output is correct
13 Correct 3 ms 524 KB Output is correct
14 Correct 2 ms 524 KB Output is correct
15 Correct 5 ms 524 KB Output is correct
16 Correct 7 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 248 KB Output is correct
2 Correct 182 ms 436 KB Output is correct
3 Correct 198 ms 496 KB Output is correct
4 Correct 141 ms 496 KB Output is correct
5 Correct 236 ms 496 KB Output is correct
6 Correct 195 ms 496 KB Output is correct
7 Correct 202 ms 524 KB Output is correct
8 Correct 225 ms 524 KB Output is correct
9 Correct 181 ms 524 KB Output is correct
10 Correct 95 ms 524 KB Output is correct
11 Correct 2 ms 524 KB Output is correct
12 Correct 2 ms 524 KB Output is correct
13 Correct 3 ms 524 KB Output is correct
14 Correct 2 ms 524 KB Output is correct
15 Correct 5 ms 524 KB Output is correct
16 Correct 7 ms 524 KB Output is correct
17 Execution timed out 2012 ms 572 KB Time limit exceeded
18 Halted 0 ms 0 KB -