結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
simauma1203
|
| 提出日時 | 2018-04-21 12:54:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,027 bytes |
| コンパイル時間 | 494 ms |
| コンパイル使用メモリ | 63,648 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-27 20:26:23 |
| 合計ジャッジ時間 | 4,958 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 10 RE * 6 |
ソースコード
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------
int a[200030];
int mx[200030];
int mn[200030];
int ans;
int main(){
string s;
REP(i,200020){
mn[i]=1145141919;
}
mn[0]=0;
cin>>s;
REP(i,s.length()){
if(s[i]=='A'){a[i+1]=a[i]+1;}
else {a[i+1]=a[i]-1;}
}
REP(i,s.length()+1){
cout<<a[i]<<endl;
mx[a[i]]=max(i,mx[a[i]]);
mn[a[i]]=min(i,mn[a[i]]);
}
REP(i,s.length()+1){
cout<<mx[i]<<" "<<mn[i]<<endl;
ans=max(mx[i]-mn[i],ans);
}
cout<<ans<<endl;
return 0;
}
simauma1203