QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#286862 | #1133. Monster Game | Mysterious_Cat | 0 | 19ms | 4080kb | C++14 | 1.7kb | 2023-12-18 20:48:02 | 2023-12-18 20:48:02 |
Judging History
answer
#include "monster.h"
#include<bits/stdc++.h>
using namespace std;
void solve(vector<int> &T, int l, int r) {
if(l == r) {
return;
}
int mid = l + r >> 1;
solve(T, l, mid);
solve(T, mid + 1, r);
vector<int> T_(r - l + 1);
for(int i = l, j = l, k = mid + 1; i <= r; i++) {
if(j > mid || (k <= r && Query(T[j], T[k]))) {
T_[i - l] = T[k++];
}
else {
T_[i - l] = T[j++];
}
}
for(int i = l; i <= r; i++) {
T[i] = T_[i - l];
}
}
vector<int> T(1000), cnt(10), Ans(1000);
bool cmp(int x, int y) {
return cnt[T[x]] < cnt[T[y]];
}
vector<int> Solve(int n) {
for(int i = 0; i < n; i++) {
T[i] = i;
}
solve(T, 0, n - 1);
vector<int> id(10);
for(int i = 0; i < min(n, 10); i++) {
id[i] = i;
for(int j = i + 1; j < min(n, 10); j++) {
if(Query(T[i], T[j])) {
cnt[T[i]]++;
}
else {
cnt[T[j]]++;
}
}
}
sort(id.begin(), id.begin() + min(n, 10), cmp);
int st = 0, ed = 0, tn = 0;
if(cnt[T[id[0]]] != cnt[T[id[1]]]) {
ed = id[0];
}
else {
if(Query(T[id[0]], T[id[1]])) {
ed = id[0];
}
else {
ed = id[1];
}
}
while(1) {
for(int i = ed; i >= st; i--) {
Ans[T[i]] = tn++;
}
if(ed == n - 1) {
break;
}
int st_ = ed + 1, ed_ = ed + 1;
while(Query(T[ed_], T[st])) {
ed_++;
}
st = st_;
ed = ed_;
}
return Ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4080kb
input:
4 0 0 1 1 0 0 1 0 1 0 1 1 1 0
output:
Q 0 1 Q 2 3 Q 0 2 Q 0 3 Q 2 3 Q 2 0 Q 2 1 Q 3 0 Q 3 1 Q 0 1 Q 2 1 Q 3 2 Q 0 2 Q 1 2 1
result:
wrong answer Wrong Answer [1]
Subtask #2:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 19ms
memory: 3792kb
input:
995 0 1 1 0 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 0 1 1 1 0 1 1 0 1 1 1 0 0 0 0 0 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 0 1 1 1 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 ...
output:
Q 0 1 Q 2 3 Q 0 3 Q 0 2 Q 1 2 Q 4 5 Q 6 7 Q 5 6 Q 5 7 Q 4 7 Q 3 6 Q 0 6 Q 0 5 Q 0 4 Q 2 4 Q 2 7 Q 8 9 Q 10 11 Q 8 11 Q 8 10 Q 9 10 Q 12 13 Q 14 15 Q 13 15 Q 13 14 Q 12 14 Q 11 15 Q 11 13 Q 8 13 Q 8 14 Q 8 12 Q 3 15 Q 6 15 Q 5 15 Q 0 15 Q 4 15 Q 7 15 Q 7 11 Q 7 13 Q 7 14 Q 2 14 Q 2 12 Q 2 8 Q 2 9 Q 1...
result:
wrong answer Wrong Answer [1]
Subtask #3:
score: 0
Wrong Answer
Test #45:
score: 0
Wrong Answer
time: 4ms
memory: 4076kb
input:
998 0 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 1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