Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int t;
- long long n, a[100000001];
- main() {
- scanf("%d", &t);
- while(t--) {
- string res, cur;
- scanf("%lld", &n);
- for(int i = 1 ; i <= n ; ++i) {
- scanf("%lld", &a[i]);
- char c = a[i] + '0';
- cur.append(1, c);
- }
- next_permutation(a + 1, a + n + 1);
- for(int i = 1 ; i <= n ; ++i) {
- char c = a[i] + '0';
- res.append(1, c);
- }
- if(cur == res) cout << "-1\n";
- else cout << res << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement