結果
問題 |
No.43 野球の試合
|
ユーザー |
|
提出日時 | 2020-03-22 00:06:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 180 ms / 5,000 ms |
コード長 | 1,121 bytes |
コンパイル時間 | 2,108 ms |
コンパイル使用メモリ | 78,484 KB |
実行使用メモリ | 42,748 KB |
最終ジャッジ日時 | 2024-12-24 02:52:57 |
合計ジャッジ時間 | 4,418 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { long t = System.currentTimeMillis(); new Main().run(); System.err.println(System.currentTimeMillis() - t); } void run() { Scanner sc = new Scanner(System.in); int N=sc.nextInt(); char[][] m=new char[N][N]; for(int i=0;i<N;++i)m[i]=sc.next().toCharArray(); int ans=Integer.MAX_VALUE/3; for(int s=0;s<1L<<(N*(N-1)/2);++s) { int[] a=new int[N]; int pos=0; for(int i=0;i<N;++i) { for(int j=i+1;j<N;++j) { if(m[i][j]=='-') { if((s>>pos)%2==1) { a[i]++; }else { a[j]++; } }else if(m[i][j]=='o'){ ++a[i]; }else { ++a[j]; } ++pos; } } int get=a[0]; Arrays.sort(a); int cur=a.length-1; int tmp=1; while(a[cur]!=get) { --cur; if(a[cur]!=a[cur+1])++tmp; } ans=Math.min(ans, tmp); } System.out.println(ans); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }