提出 #895862
ソースコード 拡げる
package main
import "fmt"
func main() {
var r, c, n int
fmt.Scan(&r)
fmt.Scan(&c)
fmt.Scan(&n)
grid := make(map[int]map[int]int)
var curr int
for i := 0; i < n; i++ {
fmt.Scan(&r)
fmt.Scan(&c)
fmt.Scan(&curr)
if grid[r] == nil {
grid[r] = (make(map[int]int))
}
grid[r][c] = curr
}
isSurpriseGrid(r, c, n, grid)
}
func isSurpriseGrid(r int, c int, n int, grid map[int]map[int]int) {
notSurprise := false
for i := 0; i < (n - 1); i++ {
if notSurprise {
fmt.Println("No")
return
}
topLeft := grid[i][i]
bottomLeft := grid[i][i+1]
topRight := grid[i+1][i]
bottomRight := grid[i+1][i+1]
if topLeft >= 0 && bottomLeft >= 0 && topRight >= 0 && bottomRight >= 0 { // can skip the current row
} else if topLeft < 0 && (bottomLeft >= 0 && topRight >= 0 && bottomRight >= 0) {
// find a value for top left
if (bottomLeft+topRight)-bottomRight > 0 {
grid[i][i] = (bottomLeft + topRight) - bottomRight
} else {
notSurprise = true
}
} else if bottomRight < 0 && (topRight >= 0 && topLeft >= 0 && bottomRight >= 0) {
if (bottomLeft+topRight)-topLeft > 0 {
grid[i+1][i+1] = (bottomLeft + topRight) - topLeft
} else {
notSurprise = true
}
} else if bottomLeft < 0 && (topLeft >= 0 && topRight >= 0 && bottomRight >= 0) {
if (topLeft+bottomRight)-topRight > 0 {
grid[i][i+1] = (topLeft + bottomRight) - topRight
} else {
notSurprise = true
}
} else if topRight < 0 && (topLeft >= 0 && bottomLeft >= 0 && bottomRight >= 0) {
if (topLeft+bottomRight)-bottomLeft > 0 {
grid[i+1][i] = (topLeft + bottomRight) - bottomLeft
} else {
notSurprise = true
}
} else {
notSurprise = true
} // always need to check current 4 are a valid config
if (topLeft + bottomRight) != (bottomLeft + topRight) {
notSurprise = true
}
}
fmt.Println("Yes")
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - マス目と整数 |
| ユーザ | katopotato |
| 言語 | Go (1.6) |
| 得点 | 0 |
| コード長 | 1930 Byte |
| 結果 | WA |
| 実行時間 | 2103 ms |
| メモリ | 22400 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 800 | ||||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_00.txt | AC | 2 ms | 512 KiB |
| 0_01.txt | AC | 2 ms | 512 KiB |
| 0_02.txt | AC | 2 ms | 512 KiB |
| 0_03.txt | AC | 2 ms | 512 KiB |
| 0_04.txt | AC | 2 ms | 512 KiB |
| 1_00.txt | AC | 2 ms | 512 KiB |
| 1_01.txt | AC | 2 ms | 512 KiB |
| 1_02.txt | AC | 2 ms | 512 KiB |
| 1_03.txt | WA | 2 ms | 512 KiB |
| 1_04.txt | AC | 2 ms | 512 KiB |
| 1_05.txt | WA | 2 ms | 512 KiB |
| 1_06.txt | TLE | 2103 ms | 22400 KiB |
| 1_07.txt | TLE | 2103 ms | 13952 KiB |
| 1_08.txt | TLE | 2103 ms | 18944 KiB |
| 1_09.txt | TLE | 2103 ms | 18944 KiB |
| 1_10.txt | TLE | 2103 ms | 12032 KiB |
| 1_11.txt | TLE | 2103 ms | 12288 KiB |
| 1_12.txt | TLE | 2103 ms | 12160 KiB |
| 1_13.txt | TLE | 2103 ms | 12544 KiB |
| 1_14.txt | TLE | 2103 ms | 12672 KiB |
| 1_15.txt | TLE | 2103 ms | 11904 KiB |
| 1_16.txt | TLE | 2103 ms | 15616 KiB |
| 1_17.txt | TLE | 2103 ms | 14592 KiB |
| 1_18.txt | TLE | 2103 ms | 15488 KiB |
| 1_19.txt | TLE | 2103 ms | 14208 KiB |
| 1_20.txt | TLE | 2102 ms | 7808 KiB |
| 1_21.txt | WA | 1190 ms | 7296 KiB |
| 1_22.txt | AC | 163 ms | 2304 KiB |
| 1_23.txt | TLE | 2103 ms | 12160 KiB |
| 1_24.txt | TLE | 2102 ms | 8192 KiB |
| 1_25.txt | TLE | 2103 ms | 8832 KiB |
| 1_26.txt | AC | 239 ms | 2816 KiB |
| 1_27.txt | AC | 467 ms | 4736 KiB |
| 1_28.txt | TLE | 2103 ms | 12416 KiB |
| 1_29.txt | AC | 1380 ms | 8064 KiB |
| 1_30.txt | TLE | 2103 ms | 10624 KiB |
| 1_31.txt | AC | 1600 ms | 9984 KiB |
| 1_32.txt | TLE | 2102 ms | 5760 KiB |
| 1_33.txt | TLE | 2103 ms | 10752 KiB |
| 1_34.txt | WA | 489 ms | 4608 KiB |
| 1_35.txt | TLE | 2103 ms | 10880 KiB |
| 1_36.txt | WA | 581 ms | 4736 KiB |
| 1_37.txt | AC | 1607 ms | 7040 KiB |
| 1_38.txt | TLE | 2103 ms | 11776 KiB |
| 1_39.txt | AC | 913 ms | 6400 KiB |
| 1_40.txt | TLE | 2103 ms | 12800 KiB |
| 1_41.txt | WA | 1394 ms | 9472 KiB |
| 1_42.txt | TLE | 2102 ms | 7808 KiB |
| 1_43.txt | TLE | 2103 ms | 13440 KiB |
| 1_44.txt | TLE | 2103 ms | 13824 KiB |
| 1_45.txt | AC | 1017 ms | 4608 KiB |
| 1_46.txt | TLE | 2103 ms | 11264 KiB |
| 1_47.txt | WA | 1294 ms | 4864 KiB |
| 1_48.txt | AC | 1210 ms | 6400 KiB |
| 1_49.txt | AC | 385 ms | 4480 KiB |
| 1_50.txt | TLE | 2103 ms | 12800 KiB |
| 1_51.txt | TLE | 2103 ms | 10752 KiB |
| 1_52.txt | AC | 256 ms | 3072 KiB |
| 1_53.txt | AC | 593 ms | 4736 KiB |
| 1_54.txt | WA | 1229 ms | 7296 KiB |
| 1_55.txt | WA | 1672 ms | 10368 KiB |
| 1_56.txt | TLE | 2103 ms | 13184 KiB |
| 1_57.txt | TLE | 2103 ms | 8704 KiB |
| 1_58.txt | TLE | 2103 ms | 12416 KiB |
| 1_59.txt | AC | 187 ms | 2432 KiB |
| 1_60.txt | WA | 2 ms | 512 KiB |
| 1_61.txt | WA | 2 ms | 512 KiB |
| 1_62.txt | WA | 2 ms | 512 KiB |
| 1_63.txt | AC | 2 ms | 512 KiB |