3124 | 2023-02-18 15:48:11 | mraron | Következő permutáció | cpp17 | Accepted 100/100 | 293ms | 6436 KiB |
#include<bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int T;
cin>>T;
while(T--) {
int n;
cin>>n;
vector<int> p1(n),p2(n);
for(int i=0;i<n;++i) {
int x;
cin>>x;
p1[i]=x;
p2[i]=x;
}
if(prev_permutation(p1.begin(), p1.end())) {
for(int i:p1) cout<<i<<" ";
cout<<"\n";
}else cout<<"-1\n";
if(next_permutation(p2.begin(), p2.end())) {
for(int i:p2) cout<<i<<" ";
cout<<"\n";
}else cout<<"-1\n";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 50/50 | ||||||
1 | Accepted | 3ms | 1700 KiB | ||||
2 | Accepted | 3ms | 1864 KiB | ||||
3 | Accepted | 3ms | 2076 KiB | ||||
4 | Accepted | 3ms | 2300 KiB | ||||
5 | Accepted | 3ms | 2500 KiB | ||||
6 | Accepted | 4ms | 2588 KiB | ||||
7 | Accepted | 17ms | 2716 KiB | ||||
8 | Accepted | 137ms | 2928 KiB | ||||
subtask2 | 50/50 | ||||||
1 | Accepted | 293ms | 6340 KiB | ||||
2 | Accepted | 291ms | 6436 KiB |