QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#873122#8320. 种树rsy_Compile Error//C++141.1kb2025-01-26 09:37:022025-01-26 09:37:03

Judging History

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

  • [2025-01-26 09:37:03]
  • 评测
  • [2025-01-26 09:37:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 80;
__int128 f[maxn][maxn];
int A[maxn * 2], idx;
vector<int> e[maxn];
int stk[maxn * 2], n;
void init(int n) {
	f[n][n - 1] = 1;
	for (int i = n - 1; i >= 0; i--)
		for (int j = i; j >= 0; j--)
			f[i][j] = f[i + 1][j] + f[i][j + 1];
}
void dfs(int u) {
	A[++idx] = 0;
	for (auto v : e[u]) dfs(v);
	A[++idx] = 1;
}
__int128 encoder(int n, const int *p) {
	init(n);
	for (int i = 1; i <= n; i++) e[i].clear();
	for (int i = 2; i <= n; i++) e[p[i]].push_back(i);
	idx = 0;
	dfs(1);
	__int128 rk = 0;
	for (int i = 2, x = 0, y = 0; i < n * 2; i++) {
		if (A[i] == 1) rk += f[x + 1][y], y++;
		else x++;
	}
	return rk + 1;
}
void decoder(int n, __int128 M, int *p) {
	init(n);
	__int128 rk = 0;
	A[1] = 0;
	for (int i = 2, x = 0, y = 0; i < n * 2; i++) {
		if (rk + f[x + 1][y] >= M) A[i] = 0, x++;
		else rk += f[x + 1][y], A[i] = 1, y++;
	}
	A[n * 2] = 1;
	int u = 0, top = 0;
	for (int i = 1; i <= n * 2; i++) {
		if (A[i] == 0) stk[++top] = ++u, p[u] = stk[top - 1];
		else top--;
	}
}

Details

grader_decoder.cpp: In function ‘__int128 unsigned {anonymous}::read()’:
grader_decoder.cpp:9:45: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 | #define gc() ((buff == buf + 100000 ? (fread(buf,1,100000,stdin),buff = buf) : 0),*(buff++))
      |                                        ~~~~~^~~~~~~~~~~~~~~~~~~~
grader_decoder.cpp:12:17: note: in expansion of macro ‘gc’
   12 |         int c = gc();
      |                 ^~
grader_decoder.cpp:9:45: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 | #define gc() ((buff == buf + 100000 ? (fread(buf,1,100000,stdin),buff = buf) : 0),*(buff++))
      |                                        ~~~~~^~~~~~~~~~~~~~~~~~~~
grader_decoder.cpp:13:39: note: in expansion of macro ‘gc’
   13 |         while(c < '0' || c > '9') c = gc();
      |                                       ^~
grader_decoder.cpp:9:45: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 | #define gc() ((buff == buf + 100000 ? (fread(buf,1,100000,stdin),buff = buf) : 0),*(buff++))
      |                                        ~~~~~^~~~~~~~~~~~~~~~~~~~
grader_decoder.cpp:14:62: note: in expansion of macro ‘gc’
   14 |         while(c >= '0' && c <= '9') x = x * 10 + c - '0',c = gc();
      |                                                              ^~
/usr/bin/ld: /tmp/ccFQ2FkD.o: in function `main':
grader_decoder.cpp:(.text.startup+0x4d9): undefined reference to `decoder(int, unsigned __int128, int*)'
collect2: error: ld returned 1 exit status