結果
問題 | No.812 Change of Class |
ユーザー | ccppjsrb |
提出日時 | 2020-08-13 22:42:31 |
言語 | Go (1.22.1) |
結果 |
AC
|
実行時間 | 220 ms / 4,000 ms |
コード長 | 2,448 bytes |
コンパイル時間 | 12,669 ms |
コンパイル使用メモリ | 222,336 KB |
実行使用メモリ | 28,160 KB |
最終ジャッジ日時 | 2024-04-18 01:54:15 |
合計ジャッジ時間 | 18,670 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 175 ms
20,992 KB |
testcase_01 | AC | 27 ms
6,912 KB |
testcase_02 | AC | 91 ms
13,312 KB |
testcase_03 | AC | 204 ms
23,168 KB |
testcase_04 | AC | 175 ms
21,120 KB |
testcase_05 | AC | 204 ms
26,496 KB |
testcase_06 | AC | 167 ms
26,112 KB |
testcase_07 | AC | 5 ms
5,376 KB |
testcase_08 | AC | 3 ms
5,376 KB |
testcase_09 | AC | 191 ms
27,856 KB |
testcase_10 | AC | 209 ms
28,160 KB |
testcase_11 | AC | 25 ms
8,832 KB |
testcase_12 | AC | 124 ms
24,772 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 133 ms
19,712 KB |
testcase_16 | AC | 9 ms
6,016 KB |
testcase_17 | AC | 121 ms
22,472 KB |
testcase_18 | AC | 93 ms
16,384 KB |
testcase_19 | AC | 102 ms
17,920 KB |
testcase_20 | AC | 220 ms
26,836 KB |
testcase_21 | AC | 89 ms
15,488 KB |
testcase_22 | AC | 38 ms
10,752 KB |
testcase_23 | AC | 7 ms
5,376 KB |
testcase_24 | AC | 12 ms
6,272 KB |
testcase_25 | AC | 29 ms
9,344 KB |
testcase_26 | AC | 168 ms
23,296 KB |
testcase_27 | AC | 151 ms
22,528 KB |
testcase_28 | AC | 103 ms
18,304 KB |
testcase_29 | AC | 25 ms
7,552 KB |
testcase_30 | AC | 135 ms
19,840 KB |
testcase_31 | AC | 110 ms
17,280 KB |
testcase_32 | AC | 50 ms
11,776 KB |
testcase_33 | AC | 129 ms
22,400 KB |
testcase_34 | AC | 11 ms
6,016 KB |
testcase_35 | AC | 25 ms
8,576 KB |
testcase_36 | AC | 11 ms
6,144 KB |
testcase_37 | AC | 60 ms
12,032 KB |
testcase_38 | AC | 12 ms
6,528 KB |
testcase_39 | AC | 65 ms
13,056 KB |
testcase_40 | AC | 17 ms
7,296 KB |
testcase_41 | AC | 8 ms
5,632 KB |
testcase_42 | AC | 138 ms
19,840 KB |
testcase_43 | AC | 32 ms
12,416 KB |
testcase_44 | AC | 94 ms
16,000 KB |
testcase_45 | AC | 11 ms
6,272 KB |
testcase_46 | AC | 26 ms
11,264 KB |
testcase_47 | AC | 90 ms
15,360 KB |
testcase_48 | AC | 101 ms
19,024 KB |
testcase_49 | AC | 27 ms
8,960 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 31 ms
9,600 KB |
testcase_52 | AC | 56 ms
16,512 KB |
testcase_53 | AC | 18 ms
7,296 KB |
testcase_54 | AC | 15 ms
7,936 KB |
testcase_55 | AC | 107 ms
18,560 KB |
testcase_56 | AC | 141 ms
22,368 KB |
testcase_57 | AC | 147 ms
21,888 KB |
testcase_58 | AC | 70 ms
14,152 KB |
testcase_59 | AC | 156 ms
24,440 KB |
testcase_60 | AC | 1 ms
5,376 KB |
testcase_61 | AC | 1 ms
5,376 KB |
testcase_62 | AC | 1 ms
5,376 KB |
ソースコード
package main import ( "bufio" "fmt" "math/bits" "os" "strconv" ) func configure(scanner *bufio.Scanner) { scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) } func getNextString(scanner *bufio.Scanner) string { scanned := scanner.Scan() if !scanned { panic("scan failed") } return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout extra := 0 if os.Getenv("I") == "IronMan" { fp, _ = os.Open(os.Getenv("END_GAME")) extra = 100 } scanner := bufio.NewScanner(fp) configure(scanner) writer := bufio.NewWriter(wfp) defer func() { r := recover() if r != nil { fmt.Fprintln(writer, r) } writer.Flush() }() solve(scanner, writer) for i := 0; i < extra; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { n := getNextInt(scanner) m := getNextInt(scanner) g := newGraph(n) for i := 0; i < m; i++ { u := getNextInt(scanner) - 1 v := getNextInt(scanner) - 1 g.appendEdge(u, v, i) g.appendEdge(v, u, i) } q := getNextInt(scanner) for i := 0; i < q; i++ { a := getNextInt(scanner) - 1 dd := make([]int, n) vv := make([]bool, n) pp := make([]pair, 0) pp = append(pp, pair{a, 0}) vv[a] = true for len(pp) > 0 { p := pp[0] pp = pp[1:] dd[p[0]] = p[1] for _, e := range g.e[p[0]] { if vv[e.to] { continue } vv[e.to] = true pp = append(pp, pair{e.to, p[1] + 1}) } } mx := 0 cnt := 0 for j := 0; j < n; j++ { if dd[j] == 0 { continue } cnt++ if mx < dd[j] { mx = dd[j] } } if mx > 0 { mx-- } days := 32 - bits.LeadingZeros32(uint32(mx)) fmt.Fprintln(writer, fmt.Sprintf("%d %d", cnt, days)) } } type pair [2]int type vertex struct { } type edge struct { to, id int } type graph struct { v []vertex e [][]edge } func newGraph(n int) graph { return graph{ v: make([]vertex, n), e: make([][]edge, n), } } func (g *graph) appendEdge(from, to, id int) { g.e[from] = append(g.e[from], edge{ to: to, id: id, }) }