結果
| 問題 |
No.239 にゃんぱすー
|
| ユーザー |
|
| 提出日時 | 2015-09-02 10:03:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 2,000 ms |
| コード長 | 816 bytes |
| コンパイル時間 | 2,165 ms |
| コンパイル使用メモリ | 78,732 KB |
| 実行使用メモリ | 56,868 KB |
| 最終ジャッジ日時 | 2024-07-18 17:36:12 |
| 合計ジャッジ時間 | 8,929 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
import java.util.*;
import java.util.stream.*;
import static java.lang.Math.*;
public class Main {
private void solve() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
String[][] mat = new String[n][n];
int[] nyan = new int[n];
for(int r=0; r<n; r++) {
String line = sc.nextLine();
String[] sp = line.split(" ");
for(int c=0; c<n; c++) {
mat[r][c] = sp[c];
}
}
for(int r=0; r<n; r++) {
for(int c=0; c<n; c++) {
if(mat[r][c].equals("nyanpass")) { nyan[c]++; }
}
}
int cnt = 0, res = -1;
for(int i=0; i<n; i++) {
if(nyan[i] == n-1) { cnt++; res = i+1; }
}
System.out.printf("%d\n", cnt==1?res:-1);
}
public static void main(String[] args) {
new Main().solve();
}
}