QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#345242#7933. Build PermutationybyCompile Error//Java111.3kb2024-03-06 17:25:152024-03-06 17:25:16

Judging History

你现在查看的是最新测评结果

  • [2024-03-06 17:25:16]
  • 评测
  • [2024-03-06 17:25:15]
  • 提交

answer



public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n + 1];
        int[] p = new int[n + 1];
        int[] s = new int[n + 1];

        for (int i = 1; i <= n; i++) {
            a[i] = scanner.nextInt();
            b[i] = i;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (a[b[i]] > a[b[j]]) {
                    int temp = b[i];
                    b[i] = b[j];
                    b[j] = temp;
                }
            }
        }

        for (int i = 1; i <= n; i++) {
            p[b[i]] = b[n - i + 1];
        }

        for (int i = 1; i <= n; i++) {
            s[i] = a[i] + a[p[i]];
        }

        boolean flag = true;
        for (int i = 2; i <= n; i++) {
            if (s[i] != s[i - 1]) {
                flag = false;
                break;
            }
        }

        if (!flag) {
            System.out.println("-1");
            return;
        }

        for (int i = 1; i <= n; i++) {
            System.out.print(p[i] + " ");
        }
        System.out.println();
    }
}

Details

Main.java:6: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:6: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
2 errors