Skip to content

Commit 66c48eb

Browse files
committed
CF441C
1 parent f022211 commit 66c48eb

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

main/400-499/441C.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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) }

main/400-499/441C_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
}

0 commit comments

Comments
 (0)