QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751755#8363. interactivelyccCompile Error//C++202.1kb2024-11-15 20:32:302024-11-15 20:32:32

Judging History

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

  • [2024-11-15 20:32:32]
  • 评测
  • [2024-11-15 20:32:30]
  • 提交

answer

#include <bits/stdc++.h>
#include "interactive.h"
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define pb push_back
using namespace std;
using vi = vector<int>;
const int N = 505;
int n;
bool e[N][N];
int query3(int x, int y, int z) {
	vi q = {x, y, z};
	For (i, 1, n) if (i != x && i != y && i != z) q.pb(i);
	return query(q);
}
void calc(int x, int y, int z) {
	int v1 = query3(x, y, z), v2 = query3(y, x, z);
	if (v1 > v2) {
		e[y][z] = e[z][y] = 1;
		int v3 = query3(x, z, y), v4 = query3(z, x, y);
		if (v3 == v4) e[x][y] = e[y][x] = 1;
		return; 
	}
	if (v1 < v2) {
		e[x][z] = e[z][x] = 1;
		int v3 = query3(y, z, x), v4 = query3(z, y, x);
		if (v3 == v4) e[x][y] = e[y][x] = 1;
		return;
	}
	if (v1 == v2) {
		int v3 = query3(y, z, x), v4 = query3(z, y, x);
		if (v3 < v4) a[x][y] = a[y][x] = 1;
		if (v3 > v4) a[x][z] = a[z][x] = a[y][z] = a[z][y] = 1;
		return;
	}
	return;
}
vi ans;
void dfs(int x, int fa) {
	ans.pb(x);
	For (y, 1, n) if (y != fa && a[x][y]) dfs(y, x);
	return;
}
bool used[N];
int work(int d, int l, int r) {
	vi q;
	For (i, 2, l - 1) q.pb(i);
	for (int i = 0; i < d && l + i <= r; i++) {
		int p = l + i;
		if (i & 1) {
			while (p <= r && p + d <= n) p += d;
			while (p >= l) q.pb(p), p -= d;
		} else {
			while (p <= r + d && p <= n) q.pb(p), p += d;
		}
	}
	mem(used, 0);
	for (int x : q) used[x] = 1;
	rep (i, min(n, l + d - 1), 1) if (!used[i]) q.pb(i), used[i] = 1;
	For (i, r + 1, n) if (!used[i]) q.pb(i);
	int res = query(q);
	For (i, 0, n - 2) res -= e[q[i]][q[i + 1]];
	return res;
}
void solve(int d, int l, int r, int res) {
	if (!res) return;
	if (l == r) return e[l][l + d] = e[l + d][l] = 1, void(); 
	int mid = (l + r) >> 1, resl = work(d, l, mid);
	solve(d, l, mid, resl); solve(d, mid + 1, r, res - resl);
	return; 
}
vi solve(int m) {
	n = m;
	For (i, 2, n - 1) calc(1, i, i + 1);
	For (d, 2, n - 2) solve(d, 2, n - d, work(d, 2, n - d));
	For (i, 1, n) {
		int cnt = 0;
		For (j, 1, n) cnt += a[i][j];
		if (cnt == 1) {
			dfs(i, 0);
			break
		}
	}
	return ans;
}

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%*d%d", &n);
      |         ~~~~~^~~~~~~~~~~~~
implementer.cpp:40:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |         rep1(i, n) scanf("%d", &p[i]);
      |                    ~~~~~^~~~~~~~~~~~~
answer.code: In function ‘void calc(int, int, int)’:
answer.code:31:30: error: ‘a’ was not declared in this scope
   31 |                 if (v3 < v4) a[x][y] = a[y][x] = 1;
      |                              ^
answer.code:32:30: error: ‘a’ was not declared in this scope
   32 |                 if (v3 > v4) a[x][z] = a[z][x] = a[y][z] = a[z][y] = 1;
      |                              ^
answer.code: In function ‘void dfs(int, int)’:
answer.code:40:38: error: ‘a’ was not declared in this scope
   40 |         For (y, 1, n) if (y != fa && a[x][y]) dfs(y, x);
      |                                      ^
answer.code: In function ‘int work(int, int, int)’:
answer.code:56:9: error: ‘mem’ was not declared in this scope
   56 |         mem(used, 0);
      |         ^~~
answer.code:58:14: error: ‘i’ was not declared in this scope
   58 |         rep (i, min(n, l + d - 1), 1) if (!used[i]) q.pb(i), used[i] = 1;
      |              ^
answer.code:58:9: error: ‘rep’ was not declared in this scope
   58 |         rep (i, min(n, l + d - 1), 1) if (!used[i]) q.pb(i), used[i] = 1;
      |         ^~~
answer.code: In function ‘vi solve(int)’:
answer.code:77:38: error: ‘a’ was not declared in this scope
   77 |                 For (j, 1, n) cnt += a[i][j];
      |                                      ^
answer.code:80:30: error: expected ‘;’ before ‘}’ token
   80 |                         break
      |                              ^
      |                              ;
   81 |                 }
      |                 ~