結果

問題 No.1026 OGAWA's New Keyboard
ユーザー joybeeee
提出日時 2020-05-14 14:38:49
言語 Java
(openjdk 26.0.2.1)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 585 ms / 1,000 ms
+ 640µs
コード長 599 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,453 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 57,352 KB
最終ジャッジ日時 2026-08-28 12:38:43
合計ジャッジ時間 7,242 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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