QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#321432 | #6788. Heap Partition | iee | AC ✓ | 655ms | 8744kb | C++17 | 688b | 2024-02-04 18:11:16 | 2024-02-04 18:11:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<vector<int>> r;
multiset<pair<int, int>> s;
for (int i = 0, x; i < n; i++) {
cin >> x;
auto it = s.lower_bound({x + 1, -1});
int id;
if (it == s.begin()) {
id = r.size(), r.push_back({i});
} else {
it--, id = it->second;
r[id].push_back(i);
s.erase(it);
}
s.insert({x, id}), s.insert({x, id});
}
cout << r.size() << "\n";
for (auto v : r) {
cout << v.size();
for (int &i : v) {
cout << " " << i + 1;
}
cout << "\n";
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
4 4 1 2 3 4 4 2 4 3 1 4 1 1 1 1 5 3 2 1 4 1
output:
1 4 1 2 3 4 2 3 1 2 3 1 4 1 4 1 2 3 4 3 2 1 4 1 2 2 3 5
result:
ok ok
Test #2:
score: 0
Accepted
time: 655ms
memory: 8744kb
input:
72284 1 1 2 1 1 2 2 1 2 1 2 2 2 2 3 1 1 1 3 2 1 1 3 3 1 1 3 1 2 1 3 2 2 1 3 3 2 1 3 1 3 1 3 2 3 1 3 3 3 1 3 1 1 2 3 2 1 2 3 3 1 2 3 1 2 2 3 2 2 2 3 3 2 2 3 1 3 2 3 2 3 2 3 3 3 2 3 1 1 3 3 2 1 3 3 3 1 3 3 1 2 3 3 2 2 3 3 3 2 3 3 1 3 3 3 2 3 3 3 3 3 3 4 1 1 1 1 4 2 1 1 1 4 3 1 1 1 4 4 1 1 1 4 1 2 1 1 ...
output:
1 1 1 1 2 1 2 2 1 1 1 2 1 2 1 2 1 2 1 2 1 3 1 2 3 2 1 1 2 2 3 2 1 1 2 2 3 1 3 1 2 3 2 2 1 2 1 3 3 1 1 1 2 1 3 1 3 1 2 3 2 2 1 2 1 3 2 2 1 2 1 3 1 3 1 2 3 2 2 1 3 1 2 2 1 1 2 2 3 1 3 1 2 3 1 3 1 2 3 2 1 1 2 2 3 1 3 1 2 3 1 3 1 2 3 2 2 1 2 1 3 1 3 1 2 3 2 2 1 3 1 2 2 2 1 3 1 2 1 3 1 2 3 1 3 1 2 3 2 2 ...
result:
ok ok