104652024-04-02 23:59:01111Walking In The Parkcpp17Wrong answer 0/100112ms17712 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());
	}
	if(ans.size()>K){
		ans.resize(K);
	}
	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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1976 KiB
2Accepted3ms2184 KiB
subtask20/19
3Wrong answer63ms11584 KiB
4Wrong answer65ms12356 KiB
5Wrong answer71ms14000 KiB
6Accepted64ms13080 KiB
7Accepted71ms14172 KiB
8Accepted65ms13348 KiB
9Wrong answer81ms16224 KiB
subtask30/23
10Wrong answer3ms3300 KiB
11Wrong answer3ms3296 KiB
12Accepted3ms3432 KiB
13Accepted3ms3652 KiB
14Accepted3ms3640 KiB
15Wrong answer3ms3772 KiB
subtask40/16
16Wrong answer3ms4144 KiB
17Wrong answer3ms4100 KiB
18Wrong answer3ms4096 KiB
19Accepted3ms4356 KiB
20Accepted3ms4568 KiB
21Accepted3ms4520 KiB
22Wrong answer3ms4596 KiB
subtask50/42
23Wrong answer96ms13820 KiB
24Wrong answer97ms14460 KiB
25Wrong answer104ms15848 KiB
26Accepted100ms14844 KiB
27Accepted107ms16044 KiB
28Accepted98ms14988 KiB
29Wrong answer112ms17712 KiB