File tree Expand file tree Collapse file tree 2 files changed +91
-0
lines changed Expand file tree Collapse file tree 2 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "bufio"
5
+ . "fmt"
6
+ "io"
7
+ )
8
+
9
+ // github.com/EndlessCheng/codeforces-go
10
+ func CF329A (_r io.Reader , _w io.Writer ) {
11
+ in := bufio .NewReader (_r )
12
+ out := bufio .NewWriter (_w )
13
+ defer out .Flush ()
14
+
15
+ var n , cr , cc int
16
+ var s string
17
+ Fscan (in , & n )
18
+ r := make ([]int , n )
19
+ c := make ([]int , n )
20
+ for i := 0 ; i < n ; i ++ {
21
+ Fscan (in , & s )
22
+ for j , b := range s {
23
+ if b == '.' {
24
+ if r [j ] == 0 {
25
+ r [j ] = i + 1
26
+ cr ++
27
+ }
28
+ if c [i ] == 0 {
29
+ c [i ] = j + 1
30
+ cc ++
31
+ }
32
+ }
33
+ }
34
+ }
35
+ if cr == n {
36
+ for i , v := range r {
37
+ Fprintln (out , v , i + 1 )
38
+ }
39
+ } else if cc == n {
40
+ for i , v := range c {
41
+ Fprintln (out , i + 1 , v )
42
+ }
43
+ } else {
44
+ Fprint (out , - 1 )
45
+ }
46
+ }
47
+
48
+ //func main() { CF329A(os.Stdin, os.Stdout) }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "github.com/EndlessCheng/codeforces-go/main/testutil"
5
+ "testing"
6
+ )
7
+
8
+ // https://codeforces.com/problemset/problem/329/A
9
+ // https://codeforces.com/problemset/status/329/problem/A
10
+ func TestCF329A (t * testing.T ) {
11
+ // just copy from website
12
+ rawText := `
13
+ inputCopy
14
+ 3
15
+ .E.
16
+ E.E
17
+ .E.
18
+ outputCopy
19
+ 1 1
20
+ 2 2
21
+ 3 3
22
+ inputCopy
23
+ 3
24
+ EEE
25
+ E..
26
+ E.E
27
+ outputCopy
28
+ -1
29
+ inputCopy
30
+ 5
31
+ EE.EE
32
+ E.EE.
33
+ E...E
34
+ .EE.E
35
+ EE.EE
36
+ outputCopy
37
+ 3 3
38
+ 1 3
39
+ 2 2
40
+ 4 4
41
+ 5 3`
42
+ testutil .AssertEqualCase (t , rawText , 0 , CF329A )
43
+ }
You can’t perform that action at this time.
0 commit comments