結果

問題 No.239 にゃんぱすー
ユーザー 184
提出日時 2015-07-10 22:27:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 488 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 39,808 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-08 01:57:59
合計ジャッジ時間 7,306 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:47: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
    8 |         char s[101][101][31]={};int n;scanf("%d",n);
      |                                              ~^  ~
      |                                               |  |
      |                                               |  int
      |                                               int*
main.cpp:8:44: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         char s[101][101][31]={};int n;scanf("%d",n);
      |                                       ~~~~~^~~~~~~~
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%s",s[i][j]);
      |                 ~~~~~^~~~~~~~~~~~~~
main.cpp:8:44: warning: ‘n’ is used uninitialized [-Wuninitialized]
    8 |         char s[101][101][31]={};int n;scanf("%d",n);
      |                                       ~~~~~^~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	char s[101][101][31]={};int n;scanf("%d",n); 
	int b[101];
	for(int i=0;i<n;i++)b[i]=-1;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		scanf("%s",s[i][j]);
		if(strcmp(s[i][j],"nyanpass")==0){
			if(b[i]<0||b[i]==1)b[i]=1;
			else b[i]=0;
		}
	}
	int ans=0,cnt=0; 
	for(int i=0;i<n;i++)if(b[i]==1){ans=i+1;cnt++;}
	if(cnt>1)printf("-1\n");
	else printf("%d\n",ans); 
	return 0;
}
0