Development./Problem solving.

[BAEKJOON] 8958 - OX퀴즈

Chuuu_DevCamp:) 2020. 8. 17. 19:21
반응형

https://www.acmicpc.net/problem/8958

 

#include <iostream>
#include <string>
#include <vector>

#define IOS_PREDEFINE() \
( \
    (cin.tie(NULL)), \
    (cout.tie(NULL)), \ 
    (std::ios::sync_with_stdio(false)), \
    (void) 0 \
)

using namespace std;

int main()
{
    IOS_PREDEFINE();
    int TestCase = 0;
    cin >> TestCase;
    while(TestCase--)
    {
        string quizRes;
        cin >> quizRes;
        int scoreTable[81] = {0,};
        int inputSize = static_cast<int>(quizRes.length());
        for(int i = 0; i < inputSize; i++)
        {
            if(quizRes[i] == 'O') scoreTable[i+1] = scoreTable[i] + 1;
            else scoreTable[i+1] = 0;
        }
        int res = 0;
        for(int i = 0; i <= inputSize; i++)
        {
            res += scoreTable[i];
        }
        cout << res << endl;
    }
    return 0;
}