Submission #2545897
Source Code Expand
/// // File: d.go // Author: ymiyamoto // // Created on Tue May 22 00:16:32 2018 // package main import ( "fmt" ) type node struct { to, weight int } var N, M int var vals []int var graph [][]node func dfs(root, val int) bool { if vals[root] == -(1 << 30) { vals[root] = val } else { if vals[root] != val { return false } return true } for i := range graph[root] { n := graph[root][i] to := n.to weight := n.weight if !dfs(to, vals[root]+weight) { return false } } return true } func main() { fmt.Scan(&N, &M) graph = make([][]node, N+1) for i := range graph { graph[i] = make([]node, 0, 100000) } for i := 0; i < M; i++ { var L, R, D int fmt.Scan(&L, &R, &D) graph[L] = append(graph[L], node{to: R, weight: D}) graph[R] = append(graph[R], node{to: L, weight: -D}) } vals = make([]int, N+1) for i := range vals { vals[i] = -(1 << 30) } for i := 1; i <= N; i++ { if vals[i] == -(1<<30) && !dfs(i, 0) { fmt.Println("No") return } } fmt.Println("Yes") }
Submission Info
Submission Time | |
---|---|
Task | D - People on a Line |
User | mohei |
Language | Go (1.6) |
Score | 0 |
Code Size | 1097 Byte |
Status | RE |
Exec Time | 3378 ms |
Memory | 7168 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample01.txt, sample02.txt, sample03.txt, sample04.txt, sample05.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, sample01.txt, sample02.txt, sample03.txt, sample04.txt, sample05.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2478 ms | -673600 KB |
02.txt | TLE | 2484 ms | -672476 KB |
03.txt | TLE | 2479 ms | -671432 KB |
04.txt | TLE | 2478 ms | -671272 KB |
05.txt | TLE | 2675 ms | -670784 KB |
06.txt | TLE | 2574 ms | -670144 KB |
07.txt | TLE | 2477 ms | -670584 KB |
08.txt | TLE | 3270 ms | -669900 KB |
09.txt | TLE | 2473 ms | -670364 KB |
10.txt | TLE | 2476 ms | -670480 KB |
11.txt | TLE | 2476 ms | -669896 KB |
12.txt | TLE | 2479 ms | -670296 KB |
13.txt | TLE | 2474 ms | -670888 KB |
14.txt | TLE | 2482 ms | -670120 KB |
15.txt | TLE | 2675 ms | -670296 KB |
16.txt | RE | 1956 ms | -657924 KB |
17.txt | TLE | 2480 ms | -670968 KB |
18.txt | TLE | 2477 ms | -681256 KB |
19.txt | TLE | 2679 ms | -670076 KB |
20.txt | TLE | 2470 ms | -669992 KB |
21.txt | TLE | 3300 ms | -673864 KB |
22.txt | TLE | 2380 ms | -671784 KB |
23.txt | TLE | 2478 ms | -670936 KB |
24.txt | TLE | 2532 ms | -670024 KB |
25.txt | TLE | 2350 ms | -659372 KB |
26.txt | TLE | 2479 ms | -677544 KB |
27.txt | TLE | 2478 ms | -671116 KB |
28.txt | TLE | 2474 ms | -672960 KB |
29.txt | TLE | 2675 ms | -669632 KB |
30.txt | TLE | 2478 ms | -670152 KB |
31.txt | TLE | 2390 ms | -671448 KB |
32.txt | TLE | 2475 ms | -670016 KB |
33.txt | TLE | 2478 ms | -671168 KB |
34.txt | TLE | 2488 ms | -670712 KB |
35.txt | TLE | 2677 ms | -669760 KB |
36.txt | TLE | 2492 ms | -670280 KB |
37.txt | TLE | 2467 ms | -669988 KB |
38.txt | TLE | 3378 ms | -670616 KB |
39.txt | TLE | 2483 ms | -669784 KB |
40.txt | TLE | 2378 ms | -670272 KB |
41.txt | TLE | 2583 ms | -668360 KB |
42.txt | TLE | 2478 ms | -669128 KB |
sample01.txt | AC | 5 ms | 2688 KB |
sample02.txt | AC | 12 ms | 2688 KB |
sample03.txt | AC | 16 ms | 4736 KB |
sample04.txt | AC | 13 ms | 7168 KB |
sample05.txt | AC | 9 ms | 5632 KB |