結果

問題 No.457 (^^*)
ユーザー くれちーくれちー
提出日時 2016-12-08 23:54:26
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,132 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 25,300 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 02:37:43
合計ジャッジ時間 1,287 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 14 ms
4,376 KB
testcase_12 AC 29 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 50 ms
4,380 KB
testcase_15 AC 30 ms
4,380 KB
testcase_16 AC 51 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int main() {
    char s[10001];
    scanf("%s", s);

    int len = strlen(s);
    int p, f1, f2, f3, cnt;
    int i, j;

    f1 = f2 = f3 = cnt = 0;
    for (i = len - 1; i >= 0; i--) {
        if (!f1 && s[i] == ')') {
            f1 = 1;
            p = i;
        }
        else if (!f2 && f1 && s[i] == '*') f2 = 1;
        else if (!f3 && f2 && s[i] == '^') f3 = 1;

        else if (f3 && s[i] == '^') {
            for (j = i - 1; j >= 0; j--) {
                if (s[j] == '(') cnt++;
            }
            f1 = f2 = f3 = 0;
            i = p;
        }
    }
    printf("%d ", cnt);

    f1 = f2 = f3 = cnt = 0;
    for (i = 0; i < len; i++) {
        if (!f1 && s[i] == '(') {
            f1 = 1;
            p = i;
        }
        else if (!f2 && f1 && s[i] == '*') f2 = 1;
        else if (!f3 && f2 && s[i] == '^') f3 = 1;
        
        else if (f3 && s[i] == '^') {
            for (j = i + 1; j < len; j++) {
                if (s[j] == ')') cnt++;
            }
            f1 = f2 = f3 = 0;
            i = p;
        }
    }
    printf("%d\n", cnt);
    return 0;
}
0