結果
問題 |
No.1534 おなかがいたい
|
ユーザー |
![]() |
提出日時 | 2021-06-11 00:01:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 1,629 ms |
コンパイル使用メモリ | 167,192 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 12:07:28 |
合計ジャッジ時間 | 2,971 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(); int ans = 0; int flag = 0; for( int i = 0; i < N; i++ ) { if( i + 4 <= N && S.substr( i, 4 ) == "pain" ) { flag = 1; break; } if( i + 3 <= N && S.substr( i, 3 ) == "pon" ) { i += 2; ans++; } } if( flag == 0 || ans < 2 ) ans = -1; else ans--; cout << ans << endl; }