Official

A - Seats Editorial by cn449


初心者の方へ

for 文などを用いて、各 \(i\) に対して条件を満たすか判定すればよいです。

実装例

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++) if (s[i] == '#' && s[i + 1] == '.' && s[i + 2] == '#') ans++;
	cout << ans << '\n';
}

posted:
last update: