104622024-04-02 23:54:08111Walking In The Parkcpp17Wrong answer 0/100597ms523480 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]=s.empty()?-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){
		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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2056 KiB
subtask20/19
3Wrong answer65ms11532 KiB
4Wrong answer68ms12508 KiB
5Wrong answer74ms13920 KiB
6Accepted68ms12848 KiB
7Accepted74ms14012 KiB
8Wrong answer74ms14216 KiB
9Wrong answer86ms15896 KiB
subtask30/23
10Wrong answer3ms3100 KiB
11Runtime error361ms523480 KiB
12Accepted3ms3320 KiB
13Accepted3ms3332 KiB
14Accepted3ms3472 KiB
15Runtime error363ms523244 KiB
subtask40/16
16Wrong answer3ms3584 KiB
17Wrong answer3ms3604 KiB
18Runtime error381ms523220 KiB
19Accepted3ms3612 KiB
20Runtime error405ms523192 KiB
21Accepted3ms3892 KiB
22Runtime error386ms522972 KiB
subtask50/42
23Wrong answer97ms13092 KiB
24Runtime error538ms522944 KiB
25Runtime error597ms522724 KiB
26Accepted98ms14356 KiB
27Runtime error563ms522716 KiB
28Accepted98ms14364 KiB
29Runtime error515ms522700 KiB