結果

問題 No.3765 321-avoiding Grid
コンテスト
ユーザー tnakao0123
提出日時 2026-10-18 18:01:09
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 1,075 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 209 ms
コンパイル使用メモリ 52,816 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-10-18 18:01:14
合計ジャッジ時間 4,183 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 1 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3765.cc:  No.3765 321-avoiding Grid - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 500;
const int MAX_NN = MAX_N * MAX_N;

/* typedef */

/* global variables */

char s[MAX_NN + 4];

/* subroutines */

/* main */

int main() {
  int n, a, b, c;
  scanf("%d%d%d%d", &n, &a, &b, &c);
  int nn = n * n;
  
  if (a >= n) {
    fill(s, s + c, '3');
    fill(s + c, s + c + a, '1');
    fill(s + c + a, s + nn, '2');
  }
  else if (c >= n) {
    fill(s, s + a, '1');
    fill(s + a, s + a + c, '3');
    fill(s + a + c, s + nn, '2');
  }
  else { // a < n && c < n
    if (a <= c) {
      fill(s, s + a, '1');
      fill(s + a, s + (c - a), '3');
      fill(s + n, s + n + a, '3');
    }
    else {
      fill(s, s + c, '3');
      fill(s + c, s + (a - c), '1');
      fill(s + n, s + n + c, '1');
    }
    for (int u = 0; u < nn; u++)
      if (! s[u]) s[u] = '2';
  }

  for (int i = 0; i < nn; i++) {
    putchar(s[i]);
    if ((i + 1) % n == 0) putchar('\n');
  }
  
  return 0;
}
0