結果
問題 |
No.1534 おなかがいたい
|
ユーザー |
|
提出日時 | 2021-07-20 00:12:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 603 bytes |
コンパイル時間 | 1,627 ms |
コンパイル使用メモリ | 169,172 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 13:38:12 |
合計ジャッジ時間 | 3,185 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 RE * 1 |
ソースコード
#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; 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; }