結果
| 問題 | No.2073 Concon Substrings (Swap Version) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-01-10 23:57:09 | 
| 言語 | Go (1.23.4) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 19 ms / 2,000 ms | 
| コード長 | 860 bytes | 
| コンパイル時間 | 14,210 ms | 
| コンパイル使用メモリ | 238,972 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-21 12:45:57 | 
| 合計ジャッジ時間 | 13,088 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
	sc.Buffer(make([]byte, 1000), 5000000)
	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
	for 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 += tmp
		if i == 0 && ans == n {
			fmt.Println(n)
			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()
}
            
            
            
        