結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
かぼちゃ
|
| 提出日時 | 2018-04-13 23:10:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 709 bytes |
| コンパイル時間 | 660 ms |
| コンパイル使用メモリ | 64,476 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-27 16:33:00 |
| 合計ジャッジ時間 | 4,131 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 5 TLE * 1 -- * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | cout << ans << endl;
| ^~~
ソースコード
#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;
}
かぼちゃ