結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー |
|
提出日時 | 2023-01-10 22:32:35 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 991 bytes |
コンパイル時間 | 11,932 ms |
コンパイル使用メモリ | 220,928 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 12:24:49 |
合計ジャッジ時間 | 13,112 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 28 WA * 9 |
ソースコード
package mainimport ("bufio""fmt""os""strconv")var sc = bufio.NewScanner(os.Stdin)func main() {sc.Buffer(make([]byte, 1000), 500000)sc.Split(bufio.ScanWords)n := nextInt()s := nextString()a := make([][]int, 3)for i := range a {a[i] = make([]int, 3)}for i := range s {if s[i] == 'c' {a[0][i%3]++}if s[i] == 'o' {a[1][i%3]++}if s[i] == 'n' {a[2][i%3]++}}ans := 0// tmp := a[0][0]// if a[1][1] < tmp {// tmp = a[1][1]// }// if a[2][2] < tmp {// tmp = a[2][2]// }// ans += tmpfor i := range a {tmp := a[0][i]if a[1][(i+1)%3] < tmp {tmp = a[1][(i+1)%3]}if a[2][(i+2)%3] < tmp {tmp = a[2][(i+2)%3]}ans += tmpif i == 0 && ans == n {fmt.Println(ans)return}}if ans == n {ans--}fmt.Println(ans)}func nextInt() int {sc.Scan()i, e := strconv.Atoi(sc.Text())if e != nil {panic(e)}return i}func nextString() string {sc.Scan()return sc.Text()}