페이지

8958번: OX퀴즈

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


$O(nl)$


#include<cstdio>
int t;
char s[81];
int main() {
    scanf("%d", &t);
    while (t--) {
        int r = 0, c = 0;
        scanf("%s", s);
        for (int i = 0; s[i]; i++) s[i] == 'O' ? r += ++c : c = 0;
        printf("%d\n", r);
    }
    return 0;
}

댓글 없음 :

댓글 쓰기