QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#576004 | #6788. Heap Partition | Zhi_zI | AC ✓ | 644ms | 38168kb | C++17 | 1.5kb | 2024-09-19 17:51:55 | 2024-09-19 17:52:02 |
Judging History
answer
// Problem: F - F
// Contest: Virtual Judge - 24-09-18-训练赛-23浙江省赛
// URL: https://vjudge.net/contest/656323#problem/F
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const long long N=1e6+10,mod=998244353,INF=1e15;
ll n,m,k,a[N],cnt;
bool st[N];
vector<int>p[N];
void solve()
{
cin>>n;
multiset<pii>s;
for(int i=1;i<=cnt;i++)p[i].clear();
cnt=0;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)
{
if(!s.size()||(s.begin()->first)>a[i])
{
cnt++;
s.insert({a[i],cnt});
s.insert({a[i],cnt});
p[cnt].push_back(i);
//cout<<i<<' '<<cnt<<endl;
}
else{
auto it=s.begin();
if(s.rbegin()->first<=a[i])it=--s.end();
else
{
it=s.lower_bound({a[i],0});
//for(auto y:s)cout<<y.first<<'*'<<y.second<<endl;
auto x=*it;
//if(i==5)cout<<x.first<<' '<<a[i]<<' '<<x.second<<endl;
if(x.first!=a[i])it--;
}
pii t=*it;
//cout<<i<<' '<<t.second<<endl;
s.erase(it);
p[t.second].push_back(i);
s.insert({a[i],t.second});
s.insert({a[i],t.second});
}
}
cout<<cnt<<endl;
for(int i=1;i<=cnt;i++)
{
cout<<p[i].size()<<' ';
for(auto x:p[i])cout<<x<<' ';cout<<endl;
}
}
signed main()
{
cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
int T;cin>>T;
while(T--)solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 29652kb
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: 644ms
memory: 38168kb
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...
result:
ok ok