結果

問題 No.672 最長AB列
ユーザー かぼちゃかぼちゃ
提出日時 2018-04-13 23:10:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 709 bytes
コンパイル時間 1,179 ms
コンパイル使用メモリ 65,640 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 00:09:05
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout << ans << endl;
             ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define REP(i,a,n) for(int i = (a);i < (n);i++)
#define PI 3.14159265359
#define MOD 1000000007

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans;
    for(int h = s.length()/2;h > 0;h--){
        for(int j = 0;j < s.length()-h+1;j++){
        int a = 0,b = 0;
            for(int i = 0;i < h*2;i++){
                if(s[j+i] == 'A')a++;
                else b++;
            }
            if(a == b){
                ans = h;
                goto end;
            }
        }
    }
end:
    cout << ans << endl;
    return 0;
}
0