結果
問題 | No.43 野球の試合 |
ユーザー |
|
提出日時 | 2017-06-13 22:50:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,692 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 31,872 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 17:03:30 |
合計ジャッジ時間 | 803 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:93:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 93 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:100:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 100 | scanf("%s", s[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#define READ_BUFSIZE ( 1024 )#define READ_DELIMITER ( " " )int count(char* pS, char c){int count = 0;for (int i = 0; i < strlen(pS); i++){if (pS[i] == c)count++;}return(count);}int hantei(int N, char ps[6][7]){int K = count(ps[0], 'o');if (K == N-1)return 1;int kachi[7] = { 0 };for (int i = 1; i < N; i++){kachi[count(ps[i], 'o')] = 1;}int jun = 0;for (int j = K+1; j <= 6; j++){if (kachi[j] == 1)jun++;}return(++jun);}void simulate(int N, char ps[6][7], int team, int shiai, int &junni){char p1[6][7] = { "" };char p2[6][7] = { "" };memcpy(p1, ps, 6 * 7);memcpy(p2, ps, 6 * 7);if (ps[team][shiai] == '-'){p1[team][shiai] = 'o';p1[shiai][team] = 'x';p2[team][shiai] = 'x';p2[shiai][team] = 'o';}if (shiai == N-1){if (team == N-1){//順位の判定をするint h = hantei(N, p1);if (h < junni)junni = h;h = hantei(N, p2);if (h < junni)junni = h;return;}shiai = 0;team++;}elseshiai++;simulate(N, p1, team, shiai, junni);if (ps[team][shiai] == '-')simulate(N, p2, team, shiai, junni);}int main(int argc, char *argv[]){int N = 0;scanf("%d", &N);char s[6][7] = { "" };int r[6][2] = { 0 }; //勝ち,残りfor (int i = 0; i < N; i++){scanf("%s", s[i]);}/*for (int j = 0; j < N; j++){if (s[0][j] == '-') //K君未試合分{s[0][j] = 'o'; //K君が勝ったことにする → だめらしいs[j][0] = 'x';}}*/int junni = 6;simulate(N, s, 0, 0, junni);printf("%d\n", junni);return 0;}