結果

問題 No.239 にゃんぱすー
ユーザー hryshtk
提出日時 2015-08-20 22:41:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 822 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 11:00:33
合計ジャッジ時間 1,020 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%s", a[i][j]);
      |         ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int n, b[100];
char a[100][100][31];
char nya[] = "nyanpass";

int eq(char[], char[]);

int main(void) {
    scanf("%d", &n);
    int i, j;
    for(j = 0; j < n; j++) {
    for(i = 0; i < n; i++) {
        scanf("%s", a[i][j]);
    }
    }
    
    for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
        if(i == j) { continue; }
        if( ! eq(a[i][j], nya) ) {
            b[i] = 1;
            break;
        }
    }
    }
    
    int c = 0, p = -1;
    for(i = 0; i < n; i++) {
        if(b[i] == 0) {
            p = i + 1;
            c++;
        }
    }
    if(c != 1) { p = -1; }
    printf("%d\n", p);
    
    return 0;
}

int eq(char s[], char t[]) {
    int i = 0;
    while(s[i] == '\0' || t[i] == '\0') {
        if(s[i] != t[i]) { return 0; }
    }
    return (s[i] == t[i]);
}
0