結果

問題 No.3765 321-avoiding Grid
コンテスト
ユーザー apricity
提出日時 2026-07-13 03:38:42
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 51 ms / 1,000 ms
+ 593µs
コード長 708 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 84 ms
コンパイル使用メモリ 64,636 KB
実行使用メモリ 60,888 KB
最終ジャッジ日時 2026-10-16 20:52:58
合計ジャッジ時間 3,492 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/env pypy3
n,a,b,c = map(int, input().split())
s = [['0' for _ in range(n)] for _ in range(n)]
x, y = -1, -1
for i in range(n):
    for j in range(n):
        if b > 0:
            s[i][j] = '2'
            x = i
            y = j
            b -= 1

if x != n-1 and y != n-1:
    if a >= 2:
        s[x][y+1] = '1'
        s[x+1][y] = '1'
        a -= 2
    else: # c >= 2
        s[x][y+1] = '3'
        s[x+1][y] = '3'
        c -= 2

for i in range(n):
    for j in range(n):
        if s[i][j] == '0':
            if a > 0:
                s[i][j] = '1'
                a -= 1
            else:
                s[i][j] = '3'
                c -= 1

for i in range(n):
    print("".join(s[i]))
0