提出 #70624901


ソースコード 拡げる

#include <stdio.h>

    long long int a,b,c,d,total;
    char ch[1000010];
    long long int suma[300010],sumb[300010];
int main() {
    scanf("%lld %lld %lld",&a,&b,&c);
    scanf("%s",ch);
    for(int i=0;i<a;i++){
        if(ch[i]=='a'){
            suma[i+1]=suma[i]+1;
            sumb[i+1]=sumb[i];
        }
        else{
            suma[i+1]=suma[i];
            sumb[i+1]=sumb[i]+1;
        }
    }
    int hab,asu;
    for(int i=1;i<=a;i++){
        if(ch[i-1]=='a'&&asu-1>=b){
            asu--;
            hab--;
            total+=hab;
        }
        else{
        asu=-1;
        hab=0;
        for(int j=i;j<=a;j++){
            if(sumb[j]-sumb[i-1]>=c){
                break;}
            else {
                if(suma[j]-suma[i-1]>=b){
                    asu=suma[j]-suma[i-1];
                    hab++;
                    total++;
                }
            }
        }    }
    }
    printf("%lld",total);
    return 0;
}

提出情報

提出日時
問題 C - Truck Driver
ユーザ normalsigner
言語 C++23 (GCC 15.2.0)
得点 0
コード長 995 Byte
結果 WA
実行時間 > 2000 ms
メモリ 6720 KiB

コンパイルエラー

./Main.cpp: In function 'main':
./Main.cpp:23:16: warning: 'hab' may be used uninitialized [-Wmaybe-uninitialized]
   23 |             hab--;
      |                ^
./Main.cpp:19:9: note: 'hab' was declared here
   19 |     int hab,asu;
      |         ^
./Main.cpp:21:29: warning: 'asu' may be used uninitialized [-Wmaybe-uninitialized]
   21 |         if(ch[i-1]=='a'&&asu-1>=b){
      |                             ^
./Main.cpp:19:13: note: 'asu' was declared here
   19 |     int hab,asu;
      |             ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 300
結果
AC × 2
AC × 9
WA × 4
TLE × 12
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
hand.txt AC 0 ms 1512 KiB
random_01.txt TLE > 2000 ms 6508 KiB
random_02.txt TLE > 2000 ms 6492 KiB
random_03.txt TLE > 2000 ms 6496 KiB
random_04.txt TLE > 2000 ms 6448 KiB
random_05.txt AC 3 ms 6624 KiB
random_06.txt WA 3 ms 6604 KiB
random_07.txt WA 3 ms 6604 KiB
random_08.txt WA 4 ms 6604 KiB
random_09.txt TLE > 2000 ms 6456 KiB
random_10.txt TLE > 2000 ms 6456 KiB
random_11.txt TLE > 2000 ms 6492 KiB
random_12.txt TLE > 2000 ms 6376 KiB
random_13.txt TLE > 2000 ms 6456 KiB
random_14.txt WA 1996 ms 6628 KiB
random_15.txt TLE > 2000 ms 6500 KiB
random_16.txt TLE > 2000 ms 6456 KiB
random_17.txt AC 8 ms 6720 KiB
random_18.txt AC 7 ms 6500 KiB
random_19.txt TLE > 2000 ms 6548 KiB
random_20.txt AC 3 ms 6604 KiB
random_21.txt AC 3 ms 6664 KiB
random_22.txt AC 3 ms 6684 KiB
sample_01.txt AC 0 ms 1692 KiB
sample_02.txt AC 0 ms 1604 KiB