Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	string s;
	cin >> s;
	string t;
	ll ans = 0;
	rep(i, k) {
		if (s[i] == 'r') {
			ans += p;
			t += "p";
		}
		else if (s[i] == 's') {
			ans += r;
			t += "r";
		}
		else {
			ans += s;
			t += "s";
		}
	}
	for (int i = k;i < n;++i) {
		if (s[i] == 'r'&&s[i-k]!='r') {
			ans += p;
		}
		else if (s[i] == 's'&&s[i-k]!='s') {
			ans += r;
		}
		else if (s[i] == 'p' && s[i - k] != 'p') {
			ans += s;
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:16: error: conflicting declaration 'std::string s'
   63 |         string s;
      |                ^
a.cc:61:22: note: previous declaration as 'int s'
   61 |         int n, k, r, s, p;
      |                      ^
a.cc:68:22: error: invalid types 'int[int]' for array subscript
   68 |                 if (s[i] == 'r') {
      |                      ^
a.cc:72:27: error: invalid types 'int[int]' for array subscript
   72 |                 else if (s[i] == 's') {
      |                           ^
a.cc:82:22: error: invalid types 'int[int]' for array subscript
   82 |                 if (s[i] == 'r'&&s[i-k]!='r') {
      |                      ^
a.cc:82:35: error: invalid types 'int[int]' for array subscript
   82 |                 if (s[i] == 'r'&&s[i-k]!='r') {
      |                                   ^
a.cc:85:27: error: invalid types 'int[int]' for array subscript
   85 |                 else if (s[i] == 's'&&s[i-k]!='s') {
      |                           ^
a.cc:85:40: error: invalid types 'int[int]' for array subscript
   85 |                 else if (s[i] == 's'&&s[i-k]!='s') {
      |                                        ^
a.cc:88:27: error: invalid types 'int[int]' for array subscript
   88 |                 else if (s[i] == 'p' && s[i - k] != 'p') {
      |                           ^
a.cc:88:42: error: invalid types 'int[int]' for array subscript
   88 |                 else if (s[i] == 'p' && s[i - k] != 'p') {
      |                                          ^