์ฝ๋ ๋ฐ๋ก๊ฐ๊ธฐ
๋ฌธ์ ํ์ธ
ํ์ด
๊ฐ๋จํ ๊ตฌํ ๋ฌธ์ ๋ก, ์ฐ์์ผ๋ก O์ผ ๊ฒฝ์ฐ์๋ ๋งค๋ฒ sum์ ํ์ฌ count๋ฅผ ๋ํ๊ณ , count๋ฅผ 1 ์ฆ๊ฐ์ํค๋ count์ ์์์ ์ด 1์ธ ์ ์ ์ ์ํด์ผ ํฉ๋๋ค. X์ผ ๋์๋ count๋ฅผ 1๋ก ์ด๊ธฐํํด์ค๋๋ค.
์ฝ๋
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
int main()
{
int ans;
int T;
cin >> T;
while (T--) {
ans = 0;
string str = "";
cin >> str;
int tmp_score = 1;
for (int i = 0; i < str.length(); i++)
{
if (str[i] == 'X') tmp_score = 1;
else {
ans += tmp_score;
tmp_score++;
}
}
cout << ans << endl;
}
return 0;
}