|
@@ -10,6 +10,7 @@ var N int
|
|
var row, col []bool
|
|
var row, col []bool
|
|
var diag1, diag2 []bool
|
|
var diag1, diag2 []bool
|
|
|
|
|
|
|
|
+// < 0 means orignal solution, > 0 means new solution
|
|
var crossSol, plusSol [][]int = make([][]int, MAXN), make([][]int, MAXN)
|
|
var crossSol, plusSol [][]int = make([][]int, MAXN), make([][]int, MAXN)
|
|
|
|
|
|
func placeCrosses() {
|
|
func placeCrosses() {
|
|
@@ -23,15 +24,15 @@ func placeCrosses() {
|
|
}
|
|
}
|
|
crossSol[i][j] = 1
|
|
crossSol[i][j] = 1
|
|
col[j] = true
|
|
col[j] = true
|
|
- break
|
|
|
|
|
|
+ break // Important
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func placePluses() (points int) {
|
|
|
|
|
|
+func placePluses() (points int) { // It's important to figure out the state while placing pluses.
|
|
ds := make([]int, 0)
|
|
ds := make([]int, 0)
|
|
for i := 0; i < N-1; i++ {
|
|
for i := 0; i < N-1; i++ {
|
|
- ds = append(ds, i)
|
|
|
|
|
|
+ ds = append(ds, i) // Start alternately from both ends
|
|
ds = append(ds, 2*N-i-2)
|
|
ds = append(ds, 2*N-i-2)
|
|
}
|
|
}
|
|
ds = append(ds, N-1)
|
|
ds = append(ds, N-1)
|
|
@@ -69,7 +70,7 @@ func main() {
|
|
var M int
|
|
var M int
|
|
fmt.Scan(&N, &M)
|
|
fmt.Scan(&N, &M)
|
|
|
|
|
|
- row = make([]bool, MAXN)
|
|
|
|
|
|
+ row = make([]bool, MAXN) // Init all state
|
|
col = make([]bool, MAXN)
|
|
col = make([]bool, MAXN)
|
|
diag1 = make([]bool, 2*MAXN-1)
|
|
diag1 = make([]bool, 2*MAXN-1)
|
|
diag2 = make([]bool, 2*MAXN-1)
|
|
diag2 = make([]bool, 2*MAXN-1)
|
|
@@ -83,11 +84,11 @@ func main() {
|
|
var r, c int
|
|
var r, c int
|
|
fmt.Scan(&ch, &r, &c)
|
|
fmt.Scan(&ch, &r, &c)
|
|
r, c = r-1, c-1
|
|
r, c = r-1, c-1
|
|
- if ch != "+" {
|
|
|
|
|
|
+ if ch != "+" { // Is not bishop
|
|
crossSol[r][c] = -1
|
|
crossSol[r][c] = -1
|
|
row[r], col[c] = true, true
|
|
row[r], col[c] = true, true
|
|
}
|
|
}
|
|
- if ch != "x" {
|
|
|
|
|
|
+ if ch != "x" { // Is not rook
|
|
plusSol[r][c] = -1
|
|
plusSol[r][c] = -1
|
|
diag1[r+c], diag2[r-c+N-1] = true, true
|
|
diag1[r+c], diag2[r-c+N-1] = true, true
|
|
}
|
|
}
|
|
@@ -110,7 +111,7 @@ func main() {
|
|
for j := 0; j < N; j++ {
|
|
for j := 0; j < N; j++ {
|
|
if 0 < crossSol[i][j] || 0 < plusSol[i][j] {
|
|
if 0 < crossSol[i][j] || 0 < plusSol[i][j] {
|
|
var ch byte
|
|
var ch byte
|
|
- if plusSol[i][j] != 0 && crossSol[i][j] != 0 {
|
|
|
|
|
|
+ if plusSol[i][j] != 0 && crossSol[i][j] != 0 { // != 0 means original sol add new sol
|
|
ch = 'o'
|
|
ch = 'o'
|
|
} else if plusSol[i][j] != 0 {
|
|
} else if plusSol[i][j] != 0 {
|
|
ch = '+'
|
|
ch = '+'
|