結果

問題 No.239 にゃんぱすー
ユーザー srup٩(๑`н´๑)۶
提出日時 2016-08-23 21:44:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 60,276 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 00:39:51
合計ジャッジ時間 1,752 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:9: warning: ‘cnt’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |         if(cnt == 1) printf("%d\n", num);
      |         ^~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)


bool flag[110];
int main(void){
	rep(i, 110) flag[i] = true;
	int n; cin >> n;
	rep(i, n){
		rep(j, n){
			string s; cin >> s;
			if(i == j) continue;
			if(s != "nyanpass") flag[j] = false;
		}
	}

	int num, cnt;
	rep(i, n){
		if(flag[i]){
			num = i + 1;
			cnt++;
		}
	}
	if(cnt == 1) printf("%d\n", num);
	else printf("-1\n");
	return 0;
}
0