結果
問題 |
No.805 UMG
|
ユーザー |
![]() |
提出日時 | 2019-03-17 14:28:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 474 bytes |
コンパイル時間 | 630 ms |
コンパイル使用メモリ | 55,360 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 13:09:36 |
合計ジャッジ時間 | 1,757 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <iostream> #include <cassert> using namespace std; int N; string S; int main(){ cin >> N >> S; assert(N==(int)S.size()); assert(3<=N && N<=5000); int ans = 0; for(int i=0;i<N;i++){ assert(S[i]=='U' || S[i]=='M' || S[i]=='G'); } for(int i=0;i<N-1;i++){ for(int j=i+1;j<N;j++){ if((i+j)%2==1) continue; if(S[i]=='U' && S[(i+j)/2]=='M' && S[j]=='G') ans++; } } cout << ans << endl; }