結果

問題 No.43 野球の試合
ユーザー IL_mstaIL_msta
提出日時 2015-07-02 06:41:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,716 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 88,484 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 05:07:00
合計ジャッジ時間 1,397 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 18 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:66:6: warning: ‘rank’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int rank;
      ^~~~

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////


int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
    
	int N;
	cin>>N;
	int vs[6][6];
	char t;
	int aki=0;
	rep(i,N*N){
		cin>>t;
		if(t=='o'){
			vs[i/N][i%N] = 1;
		}else if(t=='x'){
			vs[i/N][i%N] = 0;
		}else if(t=='-'){
			vs[i/N][i%N] = -1;
			++aki;
		}else{
			vs[i/N][i%N] = -2;
		}
	}
	/*//負けて順位が上がる事案
	rep(i,N){
		if( vs[0][i] == -1){
			vs[0][i] = 1;
			vs[i][0] = 0;
			aki -=2;
		}
	}
	*/
	aki/=2;
	int win[6];
	int vsc[6][6];
	int mask = 1;
	int minRank=7;
	int rank;
	for(int num=0;num<(1<<aki);++num){
		rep(i,6)win[i]=0;
		mask = 1;
		rep(i,N*N){
			vsc[i/N][i%N] = vs[i/N][i%N];
		}
		rep(i,N*N){
			if(vsc[i/N][i%N] == 1){
				++win[i/N];
			}else if(vsc[i/N][i%N] == -1){
				if( (num & mask)!=0 ){
					vsc[i/N][i%N] = 1;
					vsc[i%N][i/N] = -1;
					++win[i/N];
				}else{
					vsc[i/N][i%N] = -1;
					vsc[i%N][i/N] = 1;
				}
				mask = mask<<1;
			}
		}
		/////
		int terWin = win[0];
		sort(win,win+N,greater<int>());
		int No=1;
		rep(i,N){
			if(i>0){
				if(win[i-1] != win[i]){
					++No;
				}
			}
			if(win[i] == terWin){
				rank = No;
				break;
			}
		}
		if(minRank > rank){
			minRank = rank;
		}
		/////
	}
	P(minRank);
    return 0;
}
0