From df2c740e139c4c54715d8bdd611d7c19a7c78df9 Mon Sep 17 00:00:00 2001 From: Endless Date: Mon, 27 Dec 2021 08:52:29 +0800 Subject: [PATCH] CF4C --- main/1-99/4C.go | 29 +++++++++++++++++++++++++++++ main/1-99/4C_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 main/1-99/4C.go create mode 100644 main/1-99/4C_test.go diff --git a/main/1-99/4C.go b/main/1-99/4C.go new file mode 100644 index 0000000000..c1451607a0 --- /dev/null +++ b/main/1-99/4C.go @@ -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) } diff --git a/main/1-99/4C_test.go b/main/1-99/4C_test.go new file mode 100644 index 0000000000..ebf176bad0 --- /dev/null +++ b/main/1-99/4C_test.go @@ -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) +}