10463 | 2024-04-02 23:56:02 | 111 | Walking In The Park | cpp17 | Wrong answer 0/100 | 115ms | 17492 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M,K;
cin>>N>>M>>K;
vector<int>a(N+1),b(M+1);
for(int i=1;i<=N;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(int i=1;i<=M;i++){
cin>>b[i];
b[i]+=b[i-1];
}
vector<int>z,p(N+1);
vector<int>s;
for(int i=1;i<=N;i++){
if(binary_search(b.begin()+1,b.end(),a[i])){
auto t=lower_bound(s.begin(),s.end(),a[i]);
p[i]=t==s.begin()?-1:z[t-s.begin()-1];
if(t==s.end()){
z.push_back(i);
s.push_back(a[i]);
}
else{
z[t-s.begin()]=i;
*t=a[i];
}
}
}
if(s.size()<K||z.back()!=N||a[N]!=b[M]){
cout<<-1<<'\n';
return 0;
}
vector<pair<int,int>>ans;
for(int i=p[z.back()];i>0;i=p[i]){
ans.emplace_back(i,lower_bound(b.begin(),b.end(),a[i])-b.begin());
}
reverse(ans.begin(),ans.end());
for(auto[a,b]:ans){
cout<<a<<' ';
}
cout<<'\n';
for(auto[a,b]:ans){
cout<<b<<' ';
}
cout<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2216 KiB | ||||
subtask2 | 0/19 | ||||||
3 | Wrong answer | 68ms | 11588 KiB | ||||
4 | Wrong answer | 68ms | 12196 KiB | ||||
5 | Wrong answer | 75ms | 13848 KiB | ||||
6 | Accepted | 68ms | 13012 KiB | ||||
7 | Accepted | 75ms | 14232 KiB | ||||
8 | Accepted | 70ms | 13416 KiB | ||||
9 | Wrong answer | 86ms | 16352 KiB | ||||
subtask3 | 0/23 | ||||||
10 | Wrong answer | 3ms | 3196 KiB | ||||
11 | Wrong answer | 3ms | 3324 KiB | ||||
12 | Accepted | 3ms | 3412 KiB | ||||
13 | Accepted | 3ms | 3416 KiB | ||||
14 | Accepted | 3ms | 3416 KiB | ||||
15 | Wrong answer | 3ms | 3692 KiB | ||||
subtask4 | 0/16 | ||||||
16 | Wrong answer | 3ms | 3868 KiB | ||||
17 | Wrong answer | 3ms | 4036 KiB | ||||
18 | Wrong answer | 3ms | 3944 KiB | ||||
19 | Accepted | 3ms | 3940 KiB | ||||
20 | Accepted | 3ms | 4256 KiB | ||||
21 | Accepted | 3ms | 4212 KiB | ||||
22 | Wrong answer | 3ms | 4412 KiB | ||||
subtask5 | 0/42 | ||||||
23 | Wrong answer | 101ms | 13588 KiB | ||||
24 | Wrong answer | 104ms | 14228 KiB | ||||
25 | Wrong answer | 109ms | 15632 KiB | ||||
26 | Accepted | 103ms | 14616 KiB | ||||
27 | Accepted | 108ms | 15716 KiB | ||||
28 | Accepted | 103ms | 14712 KiB | ||||
29 | Wrong answer | 115ms | 17492 KiB |