QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#742374 | #9432. Permutation | Eric998 | WA | 290ms | 3848kb | C++14 | 1.3kb | 2024-11-13 16:28:28 | 2024-11-13 16:28:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define N 1005
int fin[N], n;
void solve(int l, int r, vector<int> &v) {
if (v.size() == 1) {
fin[l] = v[0];
return;
}
shuffle(v.begin(), v.end(), mt19937());
int md = (l + r) / 2;
vector<int> lv, rv;
set<int> st;
for (int i = 0; i < v.size(); i++) {
if (lv.size() == md - l + 1) {
rv.push_back(v[i]);
continue;
} else if (rv.size() == r - md) {
lv.push_back(v[i]);
continue;
} else if (!st.size()) {
st.insert(v[i]);
continue;
}
int tp = *st.begin();
st.erase(tp);
cout << "0 ";
for (int j = 1; j <= md; j++)
cout << tp << ' ';
for (int j = md + 1; j <= n; j++)
cout << v[i] << ' ';
cout << endl;
int qry;
cin >> qry;
if (qry == 2)
lv.push_back(tp), rv.push_back(v[i]);
else if (!qry)
rv.push_back(tp), lv.push_back(v[i]);
else
st.insert(tp), st.insert(v[i]);
}
for (int it : st) {
if (lv.size() == md - l + 1)
rv.push_back(it);
else
lv.push_back(it);
}
solve(l, md, lv), solve(md + 1, r, rv);
}
int main() {
cin >> n;
vector<int> v;
for (int i = 1; i <= n; i++)
v.push_back(i);
solve(1, n, v);
cout << "1 ";
for (int i = 1; i <= n; i++)
cout << fin[i] << ' ';
cout << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3780kb
input:
5 1 2 2 2 2 0
output:
0 4 4 4 3 3 0 3 3 3 5 5 0 4 4 4 1 1 0 3 3 2 2 2 0 3 4 4 4 4 0 5 5 5 5 1 1 3 4 2 1 5
result:
ok Accepted
Test #2:
score: -100
Wrong Answer
time: 290ms
memory: 3848kb
input:
1000 0 0 2 0 1 0 0 0 0 1 0 0 0 1 2 2 0 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0 2 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 1 0 0...
output:
0 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 20...
result:
wrong answer More than 6666 quries