Skip to content

Commit

Permalink
CF4C
Browse files Browse the repository at this point in the history
  • Loading branch information
EndlessCheng committed Dec 27, 2021
1 parent 4ffedcb commit df2c740
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
29 changes: 29 additions & 0 deletions main/1-99/4C.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"bufio"
. "fmt"
"io"
)

// github.com/EndlessCheng/codeforces-go
func CF4C(_r io.Reader, _w io.Writer) {
in := bufio.NewReader(_r)
out := bufio.NewWriter(_w)
defer out.Flush()

var n int
var s string
cnt := map[string]int{}
for Fscan(in, &n); n > 0; n-- {
Fscan(in, &s)
if cnt[s] > 0 {
Fprintf(out, "%s%d\n", s, cnt[s])
} else {
Fprintln(out, "OK")
}
cnt[s]++
}
}

//func main() { CF4C(os.Stdin, os.Stdout) }
40 changes: 40 additions & 0 deletions main/1-99/4C_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"github.com/EndlessCheng/codeforces-go/main/testutil"
"testing"
)

// https://codeforces.com/problemset/problem/4/C
// https://codeforces.com/problemset/status/4/problem/C
func TestCF4C(t *testing.T) {
// just copy from website
rawText := `
inputCopy
4
abacaba
acaba
abacaba
acab
outputCopy
OK
OK
abacaba1
OK
inputCopy
6
first
first
second
second
third
third
outputCopy
OK
first1
OK
second1
OK
third1`
testutil.AssertEqualCase(t, rawText, 0, CF4C)
}

0 comments on commit df2c740

Please sign in to comment.