QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#800685#9783. Duloc Networkucup-team4454Compile Error//C++142.0kb2024-12-06 14:32:122024-12-06 14:32:16

Judging History

你现在查看的是最新测评结果

  • [2024-12-06 14:32:16]
  • 评测
  • [2024-12-06 14:32:12]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int a[205];
int N;
int query(vector<int> s) {
	for (int v : s) a[v] = 1;
	printf("? ");
	for (int i = 0; i < N; i++) printf("%d", a[i]);
	puts("");
	fflush(stdout);
	for (int v : s) a[v] = 0;
	int res;
	cin >> res;
	return res;
}
mt19937 rnd(time(0));
void solve(vector<vector<int>> node) {
	shuffle(node.begin(), node.end(), rnd);
	int n = node.size();
	if (n == 1) {
		printf("! 1");
		fflush(stdout);
		exit(0);
	}
	vector<int> g(n);
	for (int i = 0; i < n; i++) {
		g[i] = query(node[i]);
		if (g[i] == 0) {
			printf("! 0");
			fflush(stdout);
			exit(0);
		}
	}
	vector<int> A(0), vis(n), tmp(0), sum(0), fir(n);
	int pre = 0;
	for (int i = 0; i < n; i++) {
		vector<int> uu = A;
		for (int u : node[i]) A.push_back(u);
		int now = query(A);
		if (now == pre + g[i]) {
			pre = now;
			vis[i] = -1;
			tmp.push_back(i);
			sum.push_back(pre);
		} else {
			fir[i] = tmp.size() - 1;
			vis[i] = -2;
			A = uu;
		}
	}
	for (int i = 0; i < n; i++) {
		if (vis[i] == -2) {
			int l = 0, r = fir[i], res = tmp.size();
			auto check = [&](int m) -> bool {
				A.clear();
				for (int i = 0; i <= m; i++) {
					for (int u : node[tmp[i]]) {
						A.push_back(u);
					}
				}
				for (int u : node[i]) A.push_back(u);
				return query(A) != g[i] + sum[m];
			};
			while (l <= r) {
				int mid = (l + r) >> 1;
				if (check(mid)) res = mid, r = mid - 1;
				else l = mid + 1;
			}
			vis[i] = tmp[res];
		}
	}
	vector<vector<int>> n_node(0);
	for (int i = 0; i < n; i++) {
		if (vis[i] == -1) {
			vector<int> zz(0);
			for (int u : node[i]) zz.push_back(u);
			for (int j = 0; j < n; j++) {
				if (vis[j] == i) {
					for (int u : node[j]) zz.push_back(u);
				}
			}
			n_node.push_back(zz);
		}
	}
	solve(n_node);
}
int main() {
	int n;
	cin >> n;
	N = n;
	vector<vector<int>> node;
	node.resize(n);
	for (int i = 0; i < n; i++) {
		node[i].clear();
		node[i].push_back(i);
	}
	solve(node);
	return 0;
}

详细

answer.code:18:1: error: ‘mt19937’ does not name a type
   18 | mt19937 rnd(time(0));
      | ^~~~~~~
answer.code: In function ‘void solve(std::vector<std::vector<int> >)’:
answer.code:20:43: error: ‘rnd’ was not declared in this scope; did you mean ‘rand’?
   20 |         shuffle(node.begin(), node.end(), rnd);
      |                                           ^~~
      |                                           rand
answer.code:20:9: error: ‘shuffle’ was not declared in this scope
   20 |         shuffle(node.begin(), node.end(), rnd);
      |         ^~~~~~~