結果

問題 No.418 ミンミンゼミ
ユーザー Eclair1015
提出日時 2018-07-10 15:54:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 366 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 60,496 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-16 02:36:54
合計ジャッジ時間 1,461 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:17: warning: ‘flag’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |                 if (flag) {
      |                 ^~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include<string>

using namespace std;
int main(){
	string s;
	cin >> s;
	bool flag;
	int count = 0;
	for (int i = 0; i < (s.size()); i++) {
		if (s[i] == 'm' && s[i + 1] == 'i') {
			flag = true;
		}
		if (flag) {
			if (s[i] == 'n') {
				count++;
				flag = false;
			}
		}
	}
	cout << count << endl;
}

0