結果
問題 | No.43 野球の試合 |
ユーザー | kou6839 |
提出日時 | 2014-11-25 15:52:06 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 286 ms / 5,000 ms |
コード長 | 1,300 bytes |
コンパイル時間 | 3,259 ms |
コンパイル使用メモリ | 74,540 KB |
実行使用メモリ | 62,780 KB |
最終ジャッジ日時 | 2023-08-30 22:57:32 |
合計ジャッジ時間 | 4,538 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
56,020 KB |
testcase_01 | AC | 121 ms
55,968 KB |
testcase_02 | AC | 126 ms
55,668 KB |
testcase_03 | AC | 120 ms
55,868 KB |
testcase_04 | AC | 122 ms
55,980 KB |
testcase_05 | AC | 122 ms
56,024 KB |
testcase_06 | AC | 126 ms
55,868 KB |
testcase_07 | AC | 286 ms
62,780 KB |
testcase_08 | AC | 123 ms
55,832 KB |
testcase_09 | AC | 122 ms
54,272 KB |
testcase_10 | AC | 121 ms
55,924 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){ char[][] map1 = copy(map); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(map[i][j]=='-'){ map1[i][j]='o'; map1[j][i]='x'; dfs(map1,n); map1[i][j]='x'; map1[j][i]='o'; dfs(map1,n); return; } } } int[] kazu = new int[n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(map[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); } }