結果

問題 No.1764 Square
ユーザー tnakao0123tnakao0123
提出日時 2021-11-29 16:41:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 55,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 08:35:19
合計ジャッジ時間 1,713 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1764.cc:  No.1764 Square - yukicoder
 */

#include<cstdio>
#include<queue>
#include<algorithm>
 
using namespace std;

/* constant */

const int N = 4;
const char ss[N][4] = { "AE", "B", "C", "D" };

/* typedef */

typedef queue<char> qc;

/* global variables */

qc qs[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++)
    for (int j = 0; ss[i][j]; j++) qs[i].push(ss[i][j]);

  int k;
  scanf("%d", &k);

  for (int i = 0; i < k; i++) {
    int i0 = i % N, i1 = (i + 1) % N;
    char c = qs[i0].front(); qs[i0].pop();
    qs[i1].push(c);
  }

  for (int i = 0; i < N; i++) {
    while (! qs[i].empty())
      putchar(qs[i].front()), qs[i].pop();
    putchar('\n');
  }
  return 0;
}
0