Submission #963688

# Submission time Handle Problem Language Result Execution time Memory
963688 2024-04-15T13:28:41 Z yellowtoad Library (JOI18_library) C++17
0 / 100
27 ms 436 KB
#include <cstdio>
#include <vector>
#include <iostream>
#include "library.h"
using namespace std;

void Solve(int n)
{
	int x, y;
	vector<int> b(n,1), res, tmp, tmmp;
	for (int i = 1; i <= n; i++) {
		b[i-1] = 0;
		if (Query(b) == 1) {
			res.push_back(i);
			for (int j = 1; j <= n; j++) if (j != i) tmp.push_back(j);
			break;
		}
		b[i-1] = 1;
	}
	for (int i = 2; i <= n; i++) {
		int l = 0, r = tmp.size()-1;
		while (l != r) {
			int mid = (l+r)/2;
			for (int j = 0; j < n; j++) b[j] = 0;
			for (int j = 0; j < res.size(); j++) b[res[j]-1] = 1;
			for (int j = 0; j <= mid; j++) b[tmp[j]-1] = 1;
			x = Query(b);
			b[res.back()-1] = 0;
			y = Query(b);
			if (i == 2) {
				if (x == y) r = mid;
				else l = mid+1;
			} else {
				if (y > x) r = mid;
				else l = mid+1;
			}
		}
		res.push_back(tmp[l]);
		tmmp.clear();
		for (int j = 0; j < tmp.size(); j++) if (j != l) tmmp.push_back(tmp[j]);
		tmp = tmmp;
	}
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    for (int j = 0; j < res.size(); j++) b[res[j]-1] = 1;
      |                    ~~^~~~~~~~~~~~
library.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for (int j = 0; j < tmp.size(); j++) if (j != l) tmmp.push_back(tmp[j]);
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 436 KB # of queries: 2387
2 Correct 21 ms 436 KB # of queries: 2433
3 Correct 17 ms 432 KB # of queries: 2638
4 Correct 24 ms 436 KB # of queries: 2593
5 Correct 21 ms 436 KB # of queries: 2504
6 Correct 18 ms 432 KB # of queries: 2553
7 Correct 27 ms 436 KB # of queries: 2568
8 Correct 20 ms 432 KB # of queries: 2402
9 Correct 21 ms 436 KB # of queries: 2512
10 Correct 13 ms 432 KB # of queries: 1478
11 Runtime error 0 ms 436 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 436 KB # of queries: 2387
2 Correct 21 ms 436 KB # of queries: 2433
3 Correct 17 ms 432 KB # of queries: 2638
4 Correct 24 ms 436 KB # of queries: 2593
5 Correct 21 ms 436 KB # of queries: 2504
6 Correct 18 ms 432 KB # of queries: 2553
7 Correct 27 ms 436 KB # of queries: 2568
8 Correct 20 ms 432 KB # of queries: 2402
9 Correct 21 ms 436 KB # of queries: 2512
10 Correct 13 ms 432 KB # of queries: 1478
11 Runtime error 0 ms 436 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -