File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-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 CF441C (in io.Reader , _w io.Writer ) {
11
+ out := bufio .NewWriter (_w )
12
+ defer out .Flush ()
13
+
14
+ var n , m , k int
15
+ Fscan (in , & n , & m , & k )
16
+ avg := n * m / k
17
+ r := avg + n * m % k
18
+ Fprint (out , r , " " )
19
+ for i := 1 ; i <= n ; i ++ {
20
+ for j := 1 ; j <= m ; j ++ {
21
+ if r == 0 {
22
+ r = avg
23
+ Fprintln (out )
24
+ Fprint (out , r , " " )
25
+ }
26
+ if i & 1 > 0 {
27
+ Fprint (out , i , j , " " )
28
+ } else {
29
+ Fprint (out , i , m + 1 - j , " " )
30
+ }
31
+ r --
32
+ }
33
+ }
34
+ }
35
+
36
+ //func main() { CF441C(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/441/C
9
+ // https://codeforces.com/problemset/status/441/problem/C
10
+ func TestCF441C (t * testing.T ) {
11
+ // just copy from website
12
+ rawText := `
13
+ inputCopy
14
+ 3 3 3
15
+ outputCopy
16
+ 3 1 1 1 2 1 3
17
+ 3 2 1 2 2 2 3
18
+ 3 3 1 3 2 3 3
19
+ inputCopy
20
+ 2 3 1
21
+ outputCopy
22
+ 6 1 1 1 2 1 3 2 3 2 2 2 1`
23
+ testutil .AssertEqualCase (t , rawText , 0 , CF441C )
24
+ }
You can’t perform that action at this time.
0 commit comments