Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int TC = sc.nextInt();
- ArrayList<String> palabras = new ArrayList<String>();
- while (TC-- > 0) {
- palabras.clear();
- int n = sc.nextInt();
- for (int i = 0; i < n; i++) {
- String cad = sc.next();
- palabras.add(cad);
- }
- if (n == 1) {
- System.out.println(-1);
- } else {
- for (int i = 0; i < palabras.size() - 1; i++) {
- if (i > 0) {
- System.out.print(" ");
- }
- if (palabras.get(i).compareTo(palabras.get(i + 1)) < 0) {
- System.out.print(i + 2);
- } else {
- System.out.print(-1);
- }
- }
- System.out.println(" -1");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement