← Back to List

10972번: 다음 순열 ↗

Solutions

C++14
331 B | 331 chars
#include <bits/stdc++.h>
using namespace std;
int N,A;
vector <int> V;
int main()
{
    cin>>N;
    for(int x=0; x<N; x++)
    {
        cin>>A;
        V.push_back(A);
    }
    if(next_permutation(V.begin(),V.end()))
    {
        for(int x=0; x<V.size(); x++) cout<<V[x]<<" ";
    }
    else
    {
        cout<<-1;
    }
    
}