結果

問題 No.1026 OGAWA's New Keyboard
ユーザー joybeeeejoybeeee
提出日時 2020-05-14 14:38:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 792 ms / 1,000 ms
コード長 599 bytes
コンパイル時間 2,836 ms
コンパイル使用メモリ 72,724 KB
実行使用メモリ 67,120 KB
最終ジャッジ日時 2023-10-14 10:09:41
合計ジャッジ時間 10,325 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,028 KB
testcase_01 AC 121 ms
55,516 KB
testcase_02 AC 122 ms
55,716 KB
testcase_03 AC 122 ms
55,432 KB
testcase_04 AC 792 ms
65,496 KB
testcase_05 AC 227 ms
60,312 KB
testcase_06 AC 244 ms
62,452 KB
testcase_07 AC 652 ms
66,356 KB
testcase_08 AC 215 ms
60,108 KB
testcase_09 AC 131 ms
55,716 KB
testcase_10 AC 186 ms
58,648 KB
testcase_11 AC 186 ms
57,056 KB
testcase_12 AC 145 ms
56,504 KB
testcase_13 AC 121 ms
53,928 KB
testcase_14 AC 132 ms
55,648 KB
testcase_15 AC 143 ms
56,320 KB
testcase_16 AC 185 ms
55,244 KB
testcase_17 AC 435 ms
60,496 KB
testcase_18 AC 187 ms
59,256 KB
testcase_19 AC 436 ms
60,944 KB
testcase_20 AC 136 ms
55,760 KB
testcase_21 AC 121 ms
55,728 KB
testcase_22 AC 179 ms
57,256 KB
testcase_23 AC 186 ms
57,268 KB
testcase_24 AC 593 ms
67,120 KB
testcase_25 AC 189 ms
58,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Deque<Character> deque = new LinkedList<>();
      for(int i = 0; i < n; i++) {
        int t = sc.nextInt();
        char c = sc.next().charAt(0);
        if(t == 0) { // tail
          deque.addLast(c);
        } else { // head
          deque.addFirst(c);
        }
      }
      StringBuilder sb = new StringBuilder();
      while(!deque.isEmpty())
        sb.append(deque.pollFirst());
      System.out.println(sb.toString());
  }
}
0