結果

問題 No.43 野球の試合
ユーザー holegumaholeguma
提出日時 2015-08-11 17:48:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,134 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 74,304 KB
実行使用メモリ 51,428 KB
最終ジャッジ日時 2023-09-25 08:11:52
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

static class Pair{
int x;
int y;
Pair(int x,int y){
this.x=x; this.y=y;
}
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] win=new int[n];
ArrayList<Pair> array=new ArrayList<Pair>();
for(int i=0;i<n;i++){
line=br.readLine();
for(int j=0;j<n;j++){
char c=line.charAt(j);
if(c=='o') win[i]++;
if(c=='-'){
if(i<j) array.add(new Pair(i,j));
}
}
}
int ans=INF;
dfs(0,ans,win,array);
out.println(ans);
out.flush();
}
}

private static void dfs(int depth,int ans,int[] win,ArrayList<Pair> array){
if(depth==array.size()){
int r=checkRank(win);
ans=Math.min(ans,r);
return;
}
Pair p=array.get(depth);
int x=p.x;
int y=p.y;
win[x]++;
dfs(depth+1,ans,win,array);
win[x]--;
win[y]++;
dfs(depth+1,ans,win,array);
}

private static int checkRank(int[] win){
return 1;
}
}
0