結果
問題 |
No.805 UMG
|
ユーザー |
![]() |
提出日時 | 2019-08-06 22:53:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 710 bytes |
コンパイル時間 | 211 ms |
コンパイル使用メモリ | 30,848 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 13:52:27 |
合計ジャッジ時間 | 1,165 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:20:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%s", s); | ~~~~~^~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <math.h> #define Max(a, b) ((a) > (b) ? (a) : (b)) #define Min(a, b) ((a) > (b) ? (b) : (a)) #define abs(x) ((x) > 0 ? (x) : -(x)) #define rep(i, n) for(int i = 0; i < (n); i++) #define INF 1000000000000 //10^12 #define MOD 1000000007 //10^9 + 7 #define endl printf("\n") typedef long long ll; int main(int argc, char **argv) { int n; char s[5001]; scanf("%d", &n); scanf("%s", s); int cnt = 0; for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ if(s[i] == 'U' && s[j] == 'M'){ if(2 * j - i < n &&s[2 * j - i] == 'G'){ cnt++; } } } } printf("%d\n", cnt); return 0; }