Gidhub BE Developer

[BOJ] 10972. 다음 순열

2018-09-24
goodGid

Problem

Problem URL : 다음 순열


[1] Answer Code (18. 09. 24)

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    
    vector<int> v;
    while (n--) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    
    if( next_permutation(v.begin(),v.end()) ){
        for(int i=0; i<v.size(); i++)
            cout << v[i] << " ";
    }
    else{
        cout << "-1" << endl;
    }
    
    return 0;
}

Review

  • 정리해 놓은 순열 글을 읽어보자.

Recommend

Index