AtCoder Grand Contest 007

Submission #1350367

Source codeソースコード

//Do what you can't.

import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main  {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    int n = in.nextInt();
    int[] p = in.nextIntArray(n);
    int[] a = new int[n], b = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = i * n;
      b[n - 1 - i] = i * n;
    }
    for (int i = 0; i < n; i++)
      a[p[i] - 1] += i;
    for (int x : a)
      w.print((x + 1) + " ");
    w.println();
    for (int x : b)
      w.print((x + 1) + " ");
    w.close();
  }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
        throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
        c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
        return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}

Submission

Task問題 B - Construct Sequences
User nameユーザ名 ashubeckham
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 400
Source lengthソースコード長 3415 Byte
File nameファイル名
Exec time実行時間 147 ms
Memory usageメモリ使用量 29648 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0.txt,example1.txt,example2.txt
All 400 / 400 000.txt,001.txt,002.txt,003.txt,004.txt,005.txt,006.txt,007.txt,008.txt,009.txt,010.txt,011.txt,012.txt,013.txt,014.txt,015.txt,016.txt,017.txt,018.txt,example0.txt,example1.txt,example2.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
000.txt AC 90 ms 23380 KB
001.txt AC 76 ms 19028 KB
002.txt AC 75 ms 19540 KB
003.txt AC 75 ms 20180 KB
004.txt AC 88 ms 21332 KB
005.txt AC 114 ms 28244 KB
006.txt AC 94 ms 18004 KB
007.txt AC 128 ms 23636 KB
008.txt AC 105 ms 21332 KB
009.txt AC 135 ms 27092 KB
010.txt AC 131 ms 29236 KB
011.txt AC 133 ms 26324 KB
012.txt AC 139 ms 28336 KB
013.txt AC 125 ms 28116 KB
014.txt AC 136 ms 29524 KB
015.txt AC 139 ms 28848 KB
016.txt AC 147 ms 26452 KB
017.txt AC 133 ms 29648 KB
018.txt AC 137 ms 27476 KB
example0.txt AC 69 ms 19156 KB
example1.txt AC 70 ms 21076 KB
example2.txt AC 75 ms 20564 KB