Submission #63006348
Source Code Expand
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() { solve(os.Stdin, os.Stdout) }
func solve(_r io.Reader, _w io.Writer) {
in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
defer out.Flush()
s := readString(in)
st := []byte{}
for _, ch := range s {
if len(st) > 0 {
if ch == ')' && st[len(st)-1] == '(' {
st = st[:len(st)-1]
continue
}
if ch == ']' && st[len(st)-1] == '[' {
st = st[:len(st)-1]
continue
}
if ch == '>' && st[len(st)-1] == '<' {
st = st[:len(st)-1]
continue
}
}
st = append(st, byte(ch))
}
if len(st) == 0 {
fmt.Fprintln(out, "Yes")
} else {
fmt.Fprintln(out, "No")
}
}
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
func max(a, b int) int {
if a >= b {
return a
}
return b
}
func min(a, b int) int {
if a <= b {
return a
}
return b
}
func readString(reader *bufio.Reader) string {
s, _ := reader.ReadString('\n')
for i := 0; i < len(s); i++ {
if s[i] == '\n' || s[i] == '\r' {
return s[:i]
}
}
return s
}
func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}
func readNum(reader *bufio.Reader) (a int) {
bs, _ := reader.ReadBytes('\n')
readInt(bs, 0, &a)
return
}
func readTwoNums(reader *bufio.Reader) (a int, b int) {
res := readNNums(reader, 2)
a, b = res[0], res[1]
return
}
func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
res := readNNums(reader, 3)
a, b, c = res[0], res[1], res[2]
return
}
func readNNums(reader *bufio.Reader, n int) []int {
res := make([]int, n)
x := 0
bs, _ := reader.ReadBytes('\n')
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
x = readInt(bs, x, &res[i])
}
return res
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Colorful Bracket Sequence |
| User | xylu |
| Language | Go (go 1.20.6) |
| Score | 400 |
| Code Size | 2059 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 2760 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 1620 KiB |
| example_01.txt | AC | 1 ms | 1624 KiB |
| example_02.txt | AC | 1 ms | 1616 KiB |
| hand_00.txt | AC | 2 ms | 2584 KiB |
| hand_01.txt | AC | 2 ms | 2032 KiB |
| hand_02.txt | AC | 2 ms | 2584 KiB |
| hand_03.txt | AC | 1 ms | 1612 KiB |
| hand_04.txt | AC | 2 ms | 2588 KiB |
| hand_05.txt | AC | 1 ms | 1620 KiB |
| hand_06.txt | AC | 1 ms | 1616 KiB |
| random_00.txt | AC | 2 ms | 2584 KiB |
| random_01.txt | AC | 2 ms | 2456 KiB |
| random_02.txt | AC | 2 ms | 2460 KiB |
| random_03.txt | AC | 2 ms | 2280 KiB |
| random_04.txt | AC | 2 ms | 2760 KiB |
| random_05.txt | AC | 2 ms | 2280 KiB |
| random_06.txt | AC | 2 ms | 2284 KiB |
| random_07.txt | AC | 2 ms | 2224 KiB |
| random_08.txt | AC | 2 ms | 2460 KiB |
| random_09.txt | AC | 2 ms | 2284 KiB |
| random_10.txt | AC | 2 ms | 2080 KiB |
| random_11.txt | AC | 2 ms | 2100 KiB |
| random_12.txt | AC | 2 ms | 2120 KiB |
| random_13.txt | AC | 2 ms | 2100 KiB |
| random_14.txt | AC | 2 ms | 2100 KiB |
| random_15.txt | AC | 2 ms | 2036 KiB |
| random_16.txt | AC | 2 ms | 2036 KiB |
| random_17.txt | AC | 2 ms | 2036 KiB |
| random_18.txt | AC | 2 ms | 2032 KiB |
| random_19.txt | AC | 2 ms | 2040 KiB |
| random_20.txt | AC | 2 ms | 2036 KiB |
| random_21.txt | AC | 2 ms | 2036 KiB |
| random_22.txt | AC | 2 ms | 2036 KiB |
| random_23.txt | AC | 2 ms | 2028 KiB |
| random_24.txt | AC | 2 ms | 2036 KiB |
| random_25.txt | AC | 2 ms | 2040 KiB |
| random_26.txt | AC | 2 ms | 2028 KiB |
| random_27.txt | AC | 2 ms | 2028 KiB |
| random_28.txt | AC | 2 ms | 2032 KiB |
| random_29.txt | AC | 2 ms | 2036 KiB |