Submission #979072
Source Code Expand
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map.Entry; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { final Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[] perm = new int[N]; for(int i = 0; i < N; i++){ perm[i] = sc.nextInt() - 1; } int[] forward = new int[N]; int[] backward = new int[N]; for(int i = 0; i < N; i++){ forward[i] = (i + 1) * (i + 2) / 2; backward[i] = (i + 1); } for(int i = 0; i < N / 2; i ++){ final int tmp = backward[i]; backward[i] = backward[(N - 1) - i]; backward[(N - 1) - i] = tmp; } int[] new_forward = new int[N]; int[] new_backward = new int[N]; //System.out.println(Arrays.toString(backward)); for(int i = 0; i < N; i++){ new_forward[perm[i]] = forward[i]; new_backward[perm[i]] = backward[i]; } for(int i = 0; i < N; i++){ System.out.print((i == 0 ? "" : " ")); System.out.print(new_forward[i]); } System.out.println(); for(int i = 0; i < N; i++){ System.out.print((i == 0 ? "" : " ")); System.out.print(new_backward[i]); } System.out.println(); } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public void close() throws IOException { br.close(); } } }
Submission Info
Submission Time | |
---|---|
Task | B - Construct Sequences |
User | mondatto |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2463 Byte |
Status | WA |
Exec Time | 658 ms |
Memory | 20880 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt |
All | 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | WA | 194 ms | 10412 KB |
001.txt | WA | 168 ms | 9812 KB |
002.txt | WA | 152 ms | 9676 KB |
003.txt | WA | 137 ms | 9428 KB |
004.txt | WA | 174 ms | 9940 KB |
005.txt | WA | 633 ms | 19764 KB |
006.txt | WA | 262 ms | 13836 KB |
007.txt | WA | 595 ms | 19784 KB |
008.txt | WA | 431 ms | 16524 KB |
009.txt | WA | 627 ms | 20276 KB |
010.txt | WA | 655 ms | 20760 KB |
011.txt | WA | 630 ms | 19016 KB |
012.txt | WA | 642 ms | 20660 KB |
013.txt | WA | 658 ms | 20760 KB |
014.txt | WA | 644 ms | 20832 KB |
015.txt | WA | 641 ms | 20860 KB |
016.txt | WA | 636 ms | 19172 KB |
017.txt | WA | 635 ms | 19032 KB |
018.txt | WA | 653 ms | 20880 KB |
example0.txt | AC | 128 ms | 8016 KB |
example1.txt | WA | 94 ms | 8276 KB |
example2.txt | WA | 95 ms | 8144 KB |