結果
| 問題 |
No.1534 おなかがいたい
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-22 09:51:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 3,423 ms |
| コンパイル使用メモリ | 250,724 KB |
| 最終ジャッジ日時 | 2025-02-20 10:52:58 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
int main() {
string S; cin >> S;
int pos = S.find("pain");
if (pos == -1) cout << -1 << endl;
else {
int cnt = 0;
for (int i = 0; i <= pos - 3; i++) {
if (S.substr(i, 3) == "pon") cnt++;
}
if (cnt < 2) cout << -1 << endl;
else cout << cnt - 1 << endl;
}
return 0;
}