結果

問題 No.3765 321-avoiding Grid
コンテスト
ユーザー 👑 cologne
提出日時 2026-10-23 13:56:05
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 72 ms / 1,000 ms
+ 528µs
コード長 1,568 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 125 ms
コンパイル使用メモリ 64,532 KB
実行使用メモリ 63,872 KB
最終ジャッジ日時 2026-10-23 13:56:31
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import bisect
import math
import sys
from collections import defaultdict
from itertools import accumulate
from math import isqrt, inf
from typing import List, Tuple

sys.setrecursionlimit(10 ** 6)

MOD = 998244353

int1 = lambda x: int(x) - 1
input = lambda: sys.stdin.readline().rstrip('\n')
ii = lambda: int(input())
vi = lambda: list(map(int, input().split()))
vi1 = lambda: list(map(int1, input().split()))


def dbg(*args, **kwargs):
    print(*(repr(arg) for arg in args), *(f'{k}: {repr(v)}' for k, v in kwargs.items()),
          sep='; ', file=sys.stderr, flush=True)


def main():
    n, a, b, c = vi()

    arr = [[None] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if b > 0:
                arr[i][j] = 2
                pi, pj = i, j
                b -= 1
    lg = 3 if c > a else 1
    if pi != n - 1:
        arr[pi + 1][pj] = lg
        if lg == 3:
            c -= 1
        else:
            a -= 1
    if pj != n - 1:
        arr[pi][pj + 1] = lg
        if lg == 3:
            c -= 1
        else:
            a -= 1
    for i in range(n):
        for j in range(n):
            if arr[i][j] is None:
                if a > 0:
                    arr[i][j] = 1
                    a -= 1
                else:
                    arr[i][j] = 3
                    c -= 1
    for r in arr:
        print(''.join(map(str, r)))


def _start():
    if (ret := main()) is not None:
        print(*ret) if isinstance(ret, List) or isinstance(ret, Tuple) else print(ret)


if __name__ == '__main__':
    _start()
0