結果

問題 No.43 野球の試合
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-12 17:00:53
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,097 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 167,576 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 02:36:54
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int f(int, int)’:
main.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++)
#define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++)
#define all(n) (n).begin(),(n).end()
typedef long long ll;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<long long,long long> Pii;
typedef vector<Pii> VPii;

char s[6][6];

int res = 1e9;
int N;
int f(int x,int y){
	if( x >= N ) x = 0 , y++;
	if( y >= N ){
		int r[6] = {};
		for(int i = 0 ; i < N ; i++){
			for(int j = 0 ; j < N ; j++){
				if( s[i][j] == 'o' ) r[i]++;
			}
		}
		
		int rr = 0;
		vector<int> u;
		for(int i = 0 ; i < N ; i++) u.push_back(r[i]);
		sort(u.rbegin(),u.rend());
		u.erase(unique(u.begin(),u.end()),u.end());
		res = min<int>(res,find(u.begin(),u.end(),r[0]) - u.begin() + 1);
		return 0;
	}
	if( s[y][x] == '-' ){
		s[y][x] = 'o';
		s[x][y] = 'x';
		f(x+1,y);
		s[y][x] = s[x][y] = '-';
		s[y][x] = 'x';
		s[x][y] = 'o';
		f(x+1,y);
		s[y][x] = s[x][y] = '-';
	}else{
		f(x+1,y);
	}
}
int main(){
	cin >> N;
	rep(i,N)rep(j,N) cin >> s[i][j];
	
	
	f(0,0);
	cout << res << endl;
}
0