- 난이도: 브론즈 2
- 알고리즘: 문자열
OX 채점결과를 문자열로 받은 뒤 str.length와 str[j]로 접근하여 점수를 더하는 형식으로 코드를 작성하였다.
#include <iostream>
using namespace std;
int main() {
cin.tie(NULL);
cout.tie(NULL);
std::ios::sync_with_stdio(false);
int n, count = 1, total=0;
cin >> n;
string str;
for (int i = 0; i < n; i++) {
str.clear();
cin >> str;
for (int j = 0; j < str.length(); j++) {
if (str[j] == 'O') {
total += count++;
}
else {
count = 1;
}
}
cout << total << "\n";
count = 1;
total = 0;
}
}