Official

A - Seats Editorial by en_translator


For beginners

Use a control structure like a for statement to find the condition for each \(i\).

Sample code

#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: