I tried Atcoder, so it's a memo for myself. I plan to add and correct it later.
https://atcoder.jp/contests/hhkb2020
A
Q_A.go
package main
import (
"fmt"
)
func main() {
var s string
fmt.Scan(&s)
var t string
fmt.Scan(&t)
if s == "Y"{
if t == "a"{
t = "A"
} else if t == "b"{
t = "B"
} else if t == "c"{
t = "C"
}
}
fmt.Printf("%s\n", t)
}
B
Q_B.go
package main
import (
"fmt"
"strings"
)
func main() {
var H, W int
fmt.Scanf("%d %d", &H, &W)
S := make([][]string, H)
for i := 0; i < H; i++ {
var tmp string
fmt.Scanf("%s", &tmp)
S[i] = strings.Split(tmp, "")
}
var count int
//Lateral direction
for i := 0; i < H; i++ {
for j := 0; j<W-1; j++{
if S[i][j] == "." && S[i][j+1] == "."{
count += 1
}
}
}
//Longitudinal direction
for j := 0; j<W; j++{
for i := 0; i < H-1; i++ {
if S[i][j] == "." && S[i+1][j] == "."{
count += 1
}
}
}
fmt.Printf("%d\n", count)
}
C
Q_C.go
package main
import (
"fmt"
)
func main() {
var n int
fmt.Scanf("%d", &n)
p := [200001] int{}
min := 0
var s int
for i := 0; i<n; i++{
fmt.Scanf("%d", &s)
p[s] = 1
for j:=min; j<2000001; j++{
if p[min] == 1{
min ++
}else{
fmt.Printf("%d\n", min)
break
}
}
}
}
D If you remember, I will write it later.
E If you remember, I will write it later.
F If you remember, I will write it later.
Recommended Posts