結果
| 問題 |
No.1534 おなかがいたい
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2021-06-06 18:02:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 493 bytes |
| コンパイル時間 | 1,764 ms |
| コンパイル使用メモリ | 167,548 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-23 01:44:53 |
| 合計ジャッジ時間 | 2,564 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
int N = S.size();
int X = -1;
for (int i = 0; i <= N - 4; i++){
if (S.substr(i, 4) == "pain"){
X = i;
break;
}
}
if (X == -1){
cout << -1 << endl;
} else {
int cnt = 0;
for (int i = 0; i <= X - 3; i++){
if (S.substr(i, 3) == "pon"){
cnt++;
}
}
if (cnt < 2){
cout << -1 << endl;
} else {
cout << cnt - 1 << endl;
}
}
}
SSRS