結果

問題 No.1026 OGAWA's New Keyboard
ユーザー joybeeee
提出日時 2020-05-14 14:38:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 923 ms / 1,000 ms
コード長 599 bytes
コンパイル時間 2,340 ms
コンパイル使用メモリ 76,500 KB
実行使用メモリ 63,108 KB
最終ジャッジ日時 2024-09-16 05:06:39
合計ジャッジ時間 10,265 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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