QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90655#6116. Changing the Sequencesqgoi_official#WA 4ms3716kbC++141.3kb2023-03-24 15:48:322023-03-24 15:48:38

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-24 15:48:38]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3716kb
  • [2023-03-24 15:48:32]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, m, a[N], b[N], p[65], cnt[65][65], ord[65], vis[65], top = 0;
int ansp[N], ans = 0;

inline int read() {
	register int s = 0, f = 1; register char ch = getchar();
	while (!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = getchar();
	while (isdigit(ch)) s = (s * 10) + (ch & 15), ch = getchar();
	return s * f;
}

mt19937 rnd(time(0));

inline int chk() {
	int res = 0;
	for (int i = 1; i <= m; ++i) res += cnt[i][p[i]];
	if (res > ans) {
		ans = res;
		for (int i = 1; i <= m; ++i) ansp[i] = p[i];
		return -1;
	}
	for (int i = 1; i <= m; ++i) {
		if (p[ord[i]] == ansp[ord[i]]) continue;
		if (p[ord[i]] < ansp[ord[i]]) return -1;
		return res;
	} return -1;
}

inline void SA() {
	for (double t = 5000; t > 1e-6; t = t * 0.9112) {
		int x = rnd() % m + 1, y = rnd() % m + 1;
		swap(p[x], p[y]); int re = chk();
		if (x != -1) {
			if (exp((re - ans) / t) < (double)rand() / (double)RAND_MAX) swap(p[x], p[y]);
		}
	}
}

int main() {
	clock_t beg =  clock();
	n = read(); m = read();
	for (int i = 1; i <= n; ++i) a[i] = read(), p[i] = i;
	for (int i = 1; i <= n; ++i) b[i] = read(), ++cnt[a[i]][b[i]], ans += (a[i] == b[i]);
	while (clock() - beg < 1900) SA();
	for (int i = 1; i <= n; ++i) printf("%d ", ansp[a[i]]);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 3716kb

input:

4 3
2 2 3 3
2 2 2 2

output:

0 0 0 0 

result:

wrong answer 1st numbers differ - expected: '1', found: '0'