結果

問題 No.1764 Square
ユーザー tentententen
提出日時 2021-11-27 12:01:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,569 bytes
コンパイル時間 3,078 ms
コンパイル使用メモリ 75,300 KB
実行使用メモリ 49,568 KB
最終ジャッジ日時 2023-09-12 15:26:18
合計ジャッジ時間 3,244 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,324 KB
testcase_01 AC 43 ms
49,396 KB
testcase_02 AC 43 ms
49,568 KB
testcase_03 AC 42 ms
49,244 KB
testcase_04 AC 42 ms
49,408 KB
testcase_05 AC 43 ms
49,252 KB
testcase_06 AC 42 ms
49,260 KB
testcase_07 AC 42 ms
49,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        ArrayList<ArrayDeque<Character>> queues = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            queues.add(new ArrayDeque<>());
        }
        queues.get(0).add('A');
        queues.get(0).add('E');
        queues.get(1).add('B');
        queues.get(2).add('C');
        queues.get(3).add('D');
        for (int i = 0; i < n; i++) {
            queues.get((i + 1) % 4).add(queues.get(i % 4).poll());
        }
        StringBuilder sb = new StringBuilder();
        for (ArrayDeque<Character> q : queues) {
            while (q.size() > 0) {
                sb.append(q.poll());
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0