General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
187567733 Practice:
DaiRuiChen007
1641B - 36 C++14 (GCC 6-32) Accepted 46 ms 1192 KB 2023-01-02 02:59:57 2023-01-02 02:59:57
→ Source
// LUOGU_RID: 98468903
#include<bits/stdc++.h> 
#define pii pair <int,int>
using namespace std;
inline void solve() {
	int n;
	scanf("%d",&n);
	map <int,int> cnt;
	vector <int> a(n),ans;
	vector <pii> op;
	for(int i=0;i<n;++i) scanf("%d",&a[i]),++cnt[a[i]];
	for(auto p:cnt) {
		if(p.second%2==1) {
			puts("-1");
			return ;
		}
	}
	int tot=0;
	while(!a.empty()) {
		for(int i=1;i<(int)a.size();++i) {
			if(a[i]==a[0]) {
				for(int j=1;j<i;++j) op.push_back(make_pair(tot+i+j,a[j]));
				tot+=i*2,ans.push_back(i*2);
				reverse(a.begin(),a.begin()+i+1);
				a.erase(a.begin()+i),a.erase(a.begin());
				break;
			}
		}
	}
	printf("%d\n",(int)op.size());
	for(auto p:op) printf("%d %d\n",p.first,p.second);
	printf("%d\n",(int)ans.size());
	for(auto u:ans) printf("%d ",u);
	puts("");
}
signed main() {
	int T;
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details