結果

問題 No.1492 01文字列と転倒
ユーザー 小野寺健小野寺健
提出日時 2021-12-17 18:01:45
言語 Go
(1.22.1)
結果
AC  
実行時間 1,382 ms / 4,000 ms
コード長 1,165 bytes
コンパイル時間 13,453 ms
コンパイル使用メモリ 212,652 KB
実行使用メモリ 405,356 KB
最終ジャッジ日時 2023-10-12 20:57:06
合計ジャッジ時間 25,360 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1,382 ms
405,356 KB
testcase_03 AC 1,266 ms
374,336 KB
testcase_04 AC 1,172 ms
345,400 KB
testcase_05 AC 989 ms
291,680 KB
testcase_06 AC 1,033 ms
306,128 KB
testcase_07 AC 1,123 ms
330,932 KB
testcase_08 AC 1,371 ms
405,356 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 1 ms
4,356 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1,033 ms
306,124 KB
testcase_15 AC 3 ms
4,372 KB
testcase_16 AC 20 ms
7,820 KB
testcase_17 AC 985 ms
291,680 KB
testcase_18 AC 22 ms
9,944 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 15 ms
6,108 KB
testcase_21 AC 830 ms
246,212 KB
testcase_22 AC 20 ms
7,824 KB
testcase_23 AC 8 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"bufio"
	"os"
)

type Array3D struct {
	array [] int32
	xsize, ysize, zsize int32
}

func (this *Array3D) new(xsize int32, ysize int32, zsize int32) {
	this.array = make([]int32, xsize * ysize * zsize)
	this.xsize = xsize
	this.ysize = ysize
	this.zsize = zsize
}

func (this *Array3D) set(x int32, y int32, z int32, val int32) {
	this.array[x * (this.ysize * this.zsize) + y * (this.zsize) + z] = val
}

func (this *Array3D) get(x int32, y int32, z int32) int32 {
	return this.array[x * (this.ysize * this.zsize) + y * (this.zsize) + z]
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
    defer w.Flush()
	var N, M int32
	fmt.Fscan(r, &N, &M)
	dp := new(Array3D)
	dp.new(N+1, N+1, N*N+1)
	dp.set(0, 0, 0, 1)
	var i, j, k int32
	for i = 0; i <= N; i++ {
		for j = 0; j <= N; j++ {
			for k = 0; k <= N*N; k++ {
				if k+j <= N*N && i+1 <= N {
					dp.set(i+1, j, k+j, (dp.get(i+1, j, k+j) + dp.get(i, j, k)) % M)
				}
				if i >= j+1 && j+1 <= N {
					dp.set(i, j+1, k, (dp.get(i, j+1, k) + dp.get(i, j, k)) % M)
				}
			}
		}
	}
	for i = 0; i <= N*N; i++ {
		fmt.Fprintln(w, dp.get(N, N, i))
	}
}
0