結果

問題 No.672 最長AB列
ユーザー butsurizukibutsurizuki
提出日時 2018-06-15 12:17:39
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 28,260 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-13 04:34:12
合計ジャッジ時間 1,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:9:33: 警告: iteration 524288 invokes undefined behavior [-Waggressive-loop-optimizations]
    9 |     for(i=0;i<=524288;i++){rw[i]=-1;}
      |                            ~~~~~^~~
main.c:9:14: 備考: within this loop
    9 |     for(i=0;i<=524288;i++){rw[i]=-1;}
      |             ~^~~~~~~~
main.c:9:33: 警告: ‘__builtin_memset’ writing 2097156 bytes into a region of size 2097152 overflows the destination [-Wstringop-overflow=]
    9 |     for(i=0;i<=524288;i++){rw[i]=-1;}
      |                            ~~~~~^~~
main.c:7:16: 備考: destination object ‘rw’ of size 2097152
    7 |     int rs=0,i,rw[524288],res=0,l;
      |                ^~

ソースコード

diff #

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

int max(int a,int b){if(a>b){return a;}return b;}

int main(){
    int rs=0,i,rw[524288],res=0,l;
    char s[524288];
    for(i=0;i<=524288;i++){rw[i]=-1;}
    rw[250000]=0;
    scanf("%s",s);
    l=strlen(s);
    for(i=1;i<=l;i++){
        if(s[i-1]=='A'){rs++;}else{rs--;}
        if(rw[250000+rs]==-1){rw[250000+rs]=i;}
        else{res=max(res,rw[250000+rs]);}
    }
    printf("%d\n",res);
}
0