結果
問題 |
No.1534 おなかがいたい
|
ユーザー |
|
提出日時 | 2021-07-20 00:13:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 678 bytes |
コンパイル時間 | 1,572 ms |
コンパイル使用メモリ | 169,648 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 13:38:15 |
合計ジャッジ時間 | 2,480 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e+9; const ll LINF = (ll)pow(10,18); int main(){ string s; cin >> s; string t; int idx = 1e+9; if(s.size() < 4){ cout << -1 << endl; return 0; } for(int i=0; i<s.size()-3; i++){ t = s.substr(i,4); if(t == "pain"){ idx = i; break; } } if(idx == 1e+9){ cout << -1 << endl; return 0; } int ans = 0; for(int i=0; i<idx; i++){ t = s.substr(i,3); if(t == "pon") ans++; } if(ans < 2) cout << -1 << endl; else cout << ans - 1 << endl; }