結果
| 問題 | No.2509 Beam Shateki | 
| コンテスト | |
| ユーザー |  ID 21712 | 
| 提出日時 | 2025-05-02 18:01:57 | 
| 言語 | Go (1.23.4) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,535 bytes | 
| コンパイル時間 | 13,726 ms | 
| コンパイル使用メモリ | 235,148 KB | 
| 実行使用メモリ | 6,272 KB | 
| 最終ジャッジ日時 | 2025-05-02 18:02:20 | 
| 合計ジャッジ時間 | 22,570 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 40 RE * 21 | 
ソースコード
package main
import . "fmt"
func main() {
	var h, w int
	Scan(&h, &w)
	grid := make([][]int, h+2)
	for i := range grid {
		grid[i] = make([]int, w+2)
	}
	for i := 1; i <= h; i++ {
		for j := 1; j <= w; j++ {
			Scan(&grid[i][j])
		}
	}
	type Pos struct {
		row, col int
	}
	beams := [][]*Pos{}
	for i := 1; i <= h; i++ {
		b := []*Pos{}
		for j := 1; j <= w; j++{
			b = append(b, &Pos{i, j})
		}
		beams = append(beams, b)
	}
	for j := 1; j <= w; j++ {
		b := []*Pos{}
		for i := 1; i <= h; i++ {
			b = append(b, &Pos{i, j})
		}
		beams = append(beams, b)
	}
	for i := 1; i <= h; i++ {
		b := []*Pos{}
		for j := 1; i+j-1 <= h; j++ {
			b = append(b, &Pos{ i+j-1, j})
		}
		beams = append(beams, b)
	}
	for i := 1; i <= h; i++ {
		b := []*Pos{}
		for j := 1; i-j+1 >= 1; j++ {
			b = append(b, &Pos{ i-j+1, j})
		}
		beams = append(beams, b)
	}
	for j := 1; j <= w; j++ {
		b := []*Pos{}
		for i := 1; j+i-1 <= w; i++ {
			b = append(b, &Pos{ i, j+i-1 })
		}
		beams = append(beams, b)
	}
	for j := 1; j <= w; j++ {
		b := []*Pos{}
		for i := h; j+h-i <= w; i-- {
			b = append(b, &Pos{ i, j+h-i })
		}
		beams = append(beams, b)
	}
	var ans int
	for i, beam1 := range beams {
		score1 := 0
		broken := map[int]bool{}
		for _, p := range beam1 {
			score1 += grid[p.row][p.col]
			broken[p.row*(w+2)+p.col] = true
		}
		for _, beam2 := range beams[i+1:] {
			score := score1
			for _, p := range beam2 {
				if !broken[p.row*(w+2)+p.col] {
					score += grid[p.row][p.col]
				}
			}
			ans = max(ans, score)
		}
	}
	Println(ans)
}
            
            
            
        