結果
問題 | No.43 野球の試合 |
ユーザー | kou6839 |
提出日時 | 2014-11-25 15:28:34 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,267 bytes |
コンパイル時間 | 3,100 ms |
コンパイル使用メモリ | 74,452 KB |
実行使用メモリ | 56,588 KB |
最終ジャッジ日時 | 2023-08-30 22:56:24 |
合計ジャッジ時間 | 5,238 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
56,388 KB |
testcase_01 | AC | 121 ms
56,472 KB |
testcase_02 | AC | 119 ms
56,256 KB |
testcase_03 | AC | 119 ms
56,108 KB |
testcase_04 | WA | - |
testcase_05 | AC | 119 ms
56,016 KB |
testcase_06 | AC | 120 ms
56,168 KB |
testcase_07 | AC | 120 ms
55,968 KB |
testcase_08 | AC | 120 ms
56,056 KB |
testcase_09 | AC | 120 ms
56,588 KB |
testcase_10 | AC | 119 ms
55,772 KB |
ソースコード
import java.util.*; public class Main { static int ansa =7; static char[][] kekka; static char[][] copy(char[][] from){ int aa = from[0].length; char[][] to = new char[aa][aa]; for(int i=0;i<aa;i++){ for(int j=0;j<aa;j++){ to[i][j]=from[i][j]; } } return to; } static void dfs(char[][] map,int n){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(map[i][j]=='-'){ map[i][j]='o'; map[j][i]='x'; dfs(map,n); map[i][j]='x'; map[j][i]='o'; dfs(map,n); return; } } } int[] kazu = new int[n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(kekka[i][j]=='o') kazu[i]++; } } int aa=kazu[0]; Arrays.sort(kazu); int ans=1; int now=kazu[n-1]; for(int i=n-1;i>=0;i--){ if(kazu[i]<now){ ans++; now=kazu[i]; } if(now==aa){ break; } } ansa=Math.min(ansa,ans); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n= sc.nextInt(); kekka= new char[n][n]; int[] kazu = new int[n]; for(int i=0;i<n;i++){ String ss=sc.next(); for(int j=0;j<n;j++){ kekka[i][j]=ss.charAt(j); } } dfs(kekka,n); System.out.println(ansa); } }