QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#288259 | #1133. Monster Game | 000226 | 0 | 11ms | 3800kb | C++17 | 2.1kb | 2023-12-22 12:14:11 | 2023-12-22 12:14:12 |
Judging History
answer
#include "monster.h"
#include <bits/stdc++.h>
#define debug(...) fprintf (stderr, __VA_ARGS__)
void msort(std :: vector<int> &p) {
if (p.size() == 1) return ;
std :: vector<int> L, R;
int mid = p.size() >> 1; -- mid;
for (int i = 0; i <= mid; i ++) L.push_back (p[i]);
for (int i = mid + 1; i < (int) p.size(); i ++) R.push_back (p[i]);
msort (L); msort (R);
p.clear();
int i = 0, j = 0;
while (i < L.size() || j < R.size()) {
if (i == L.size()) p.push_back (R[j]), j ++;
else if (j == R.size()) p.push_back (L[i]), i ++;
else if (Query (L[i], R[j])) p.push_back (R[j]), j ++;
else p.push_back (L[i]), i ++;
}
}
inline std :: vector<int> get(std :: vector<int> p) {
std :: vector<int> ans = p;
for (int i = 0; i < (int) p.size(); i ++) ans[p[i]] = i;
return ans;
}
std :: vector<int> brute_force(int n) {
std :: vector<int> p(n), cnt(n);
std :: map<int, std :: map<int, int> > f;
std :: iota (p.begin(), p.end(), 0);
for (int i = 0; i < n; i ++)
for (int j = i + 1; j < n; j ++)
if (f[p[i]][p[j]] = f[p[j]][p[i]] = Query (p[i], p[j]))
++ cnt[p[i]]; else ++ cnt[p[j]];
std :: sort (p.begin(), p.end(), [&] (int x, int y) -> bool {
if (cnt[x] != cnt[y]) return cnt[x] < cnt[y];
return f[x][y];
} );
return p;
}
std :: vector<int> Solve(int n) {
std :: vector<int> p(n);
std :: iota (p.begin(), p.end(), 0);
if (n <= 200) {
return get (brute_force(n) );
}
msort (p);
const int m = 30;
std :: vector<int> cnt(n);
for (int i = 0; i < m; i ++)
for (int j = 0; j < m; j ++) if (i != j) if (Query (p[i], p[j])) ++ cnt[p[i]];
int m1 = -1, m2 = -1;
for (int i = 0; i < m; i ++) {
if (cnt[p[i]] == 0) std :: swap (m1, m2), m2 = i;
}
if ( Query (m1, m2)) ; else std :: swap (m1, m2);
int now = m1;
std :: reverse (p.begin(), p.begin() + now + 1);
now ++;
for (int i = now; i < n; i ++) {
if (Query (p[now - 1], p[i])) {
std :: reverse (p.begin() + now, p.begin() + i + 1);
now = i + 1;
}
}
std :: reverse (p.begin() + now, p.end());
return get (p);
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3800kb
input:
4 0 1 1 0 0 0
output:
Q 0 1 Q 0 2 Q 0 3 Q 1 2 Q 1 3 Q 2 3 F 4 3 0 1 2
result:
wrong answer Wrong Answer [3]
Subtask #2:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 11ms
memory: 3756kb
input:
995 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 0 0 1 0 0 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 0 0 0 1 1 0 1 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 1 0 0 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 0 1 0 0 1 1 1 0 1 0 1 1 0 0 1 ...
output:
Q 1 2 Q 0 2 Q 3 4 Q 5 6 Q 3 6 Q 4 6 Q 4 5 Q 0 3 Q 0 6 Q 0 5 Q 0 4 Q 2 4 Q 7 8 Q 9 10 Q 7 9 Q 8 9 Q 11 12 Q 13 14 Q 11 13 Q 12 13 Q 12 14 Q 7 11 Q 7 13 Q 7 14 Q 8 14 Q 8 12 Q 3 11 Q 6 11 Q 5 11 Q 0 11 Q 4 11 Q 2 11 Q 2 13 Q 2 7 Q 2 14 Q 2 12 Q 2 8 Q 2 9 Q 1 9 Q 15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