Skip to content

Commit 59b6e62

Browse files
committed
CF330B
1 parent 5a18180 commit 59b6e62

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

main/300-399/330B.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
)
8+
9+
// github.com/EndlessCheng/codeforces-go
10+
func CF330B(_r io.Reader, _w io.Writer) {
11+
in := bufio.NewReader(_r)
12+
out := bufio.NewWriter(_w)
13+
defer out.Flush()
14+
15+
var n, m, v int
16+
Fscan(in, &n, &m)
17+
vis := make([]bool, n+1)
18+
for m *= 2; m > 0; m-- {
19+
Fscan(in, &v)
20+
vis[v] = true
21+
}
22+
rt := 1
23+
for ; vis[rt]; rt++ {
24+
}
25+
Fprintln(out, n-1)
26+
for i := 1; i <= n; i++ {
27+
if i != rt {
28+
Fprintln(out, rt, i)
29+
}
30+
}
31+
}
32+
33+
//func main() { CF330B(os.Stdin, os.Stdout) }

main/300-399/330B_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"github.com/EndlessCheng/codeforces-go/main/testutil"
5+
"testing"
6+
)
7+
8+
// https://codeforces.com/problemset/problem/330/B
9+
// https://codeforces.com/problemset/status/330/problem/B
10+
func TestCF330B(t *testing.T) {
11+
// just copy from website
12+
rawText := `
13+
inputCopy
14+
4 1
15+
1 3
16+
outputCopy
17+
3
18+
1 2
19+
4 2
20+
2 3`
21+
testutil.AssertEqualCase(t, rawText, 0, CF330B)
22+
}

0 commit comments

Comments
 (0)