結果

問題 No.43 野球の試合
ユーザー nksk38nksk38
提出日時 2017-07-24 11:09:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,477 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 82,508 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 19:32:35
合計ジャッジ時間 1,091 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

char s[100][100];
int o[100];

int main()
{
	int n; cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> s[i][j];
			if (s[i][j] == 'o')o[i]++;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i][j] == '#')continue;
			if (i == 0) {
					if (s[i][j] == '-') {
						if (o[0] + 1 >= o[j]) {
						s[i][j] = 'o';
						s[j][i] = 'x';
						o[i]++;
					}
					else {
							s[j][i] = 'o';
							s[i][j] = 'x';
							o[j]++;
					}
				}
			}
			else {
				if (s[i][j] == '-') {
					if ((o[0] >= o[i]+1) || (o[i]+1 <= o[j])) {
						s[i][j] = 'o';
						s[j][i] = 'x';
						o[i]++;
					}
					else {
						s[j][i] = 'o';
						s[i][j] = 'x';
						o[j]++;
					}
					
				}
			}
		}
	}

	int ans = 1,score = o[0],rank=1;
	sort(o,o+n);
	reverse(o, o + n);

	for (int i = 0; i < n-1; i++) {
		if (o[i] != o[i + 1]) {
			if (o[i] == score) {
				ans = rank;
				break;
			}
			rank++;
			if (o[i + 1] == score) {
				ans = rank;
				break;
			}
		}
	}
	cout << ans << endl;
	return	0;
}

0