31242023-02-18 15:48:11mraronKövetkező permutációcpp17Accepted 100/100293ms6436 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";
    }
}
SubtaskSumTestVerdictTimeMemory
subtask150/50
1Accepted3ms1700 KiB
2Accepted3ms1864 KiB
3Accepted3ms2076 KiB
4Accepted3ms2300 KiB
5Accepted3ms2500 KiB
6Accepted4ms2588 KiB
7Accepted17ms2716 KiB
8Accepted137ms2928 KiB
subtask250/50
1Accepted293ms6340 KiB
2Accepted291ms6436 KiB