結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2016-02-24 23:33:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,115 bytes |
コンパイル時間 | 493 ms |
コンパイル使用メモリ | 66,892 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 13:25:17 |
合計ジャッジ時間 | 995 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:45:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%s", strs[i]); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <cstring>#include <iostream>#include <vector>#include <string>#include <map>#include <queue>#include <algorithm>int dfs(char strs[8][8], int wins[8], int n) {for(int i = 0; i < n; ++i) {for(int j = i + 1; j < n; ++j) {if( strs[i][j] == '-' ) {strs[i][j] = 'o';wins[i] += 1;int res = dfs(strs, wins, n);wins[i] -= 1;strs[i][j] = '-';strs[i][j] = 'x';wins[j] += 1;res = std::min(res, dfs(strs, wins, n));wins[j] -= 1;strs[i][j] = '-';return res;}}}int res = 1;int t[8] = {};for(int i = 0; i < n; ++i) {t[wins[i]] += 1;}for(int i = wins[0] + 1; i < 8; ++i) {if( t[i] != 0 ) res += t[i];}return res;}int main() {char strs[8][8];int wins[8] = {};int n;scanf("%d", &n);for(int i = 0; i < n; ++i) {scanf("%s", strs[i]);}for(int i = 0; i < n; ++i) {for(int j = 0; j < n; ++j) {if( strs[i][j] == 'o' ) {wins[i] += 1;}}}printf("%d\n", dfs(strs, wins, n));return 0;}