結果
問題 | No.43 野球の試合 |
ユーザー |
👑 ![]() |
提出日時 | 2015-08-10 12:45:41 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 22,656 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 06:29:04 |
合計ジャッジ時間 | 730 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 5 WA * 2 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:20:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration] 20 | scanf("%d\n",&n); | ^~~~~ main.c:2:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ 1 | #include<string.h> +++ |+#include <stdio.h> 2 | main.c:20:1: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch] 20 | scanf("%d\n",&n); | ^~~~~ main.c:20:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ main.c:22:25: warning: implicit declaration of function ‘getchar’ [-Wimplicit-function-declaration] 22 | for(j=0;j<n;j++)a[i][j]=getchar(),a[i][j]-'-'||t++; | ^~~~~~~ main.c:22:25: note: ‘getchar’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’? main.c:30:1: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration] 30 | printf("%d",x(a,n,s,t)); | ^~~~~~ main.c:30:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ main.c:30:1: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch] main.c:30:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
ソースコード
#include<string.h>int x(int a[][6],int n,int s,int t){int b[6]={},c[6][6]={},i=0,j=0,f=1,w,l;if(t==0){for(i=1;i<n;i++)for(j=0;j<n;j++)if(a[i][j]=='o')b[i]++;for(i=n;i>2;i--)for(j=2;j<i;j++)if(b[j-1]>b[j])b[j-1]^=b[j]^=b[j-1]^=b[j];for(i=1;i<n;i++)if(b[i]>s&&b[i-1]!=b[i])f++;return f;}for(i=1;i<n&&a[i][j]!='-';i++)for(j=i+1;j<n&&a[i][j]!='-';j++);memcpy(c,a,144);c[i][j]='o';c[j][i]='x';w=x(c,n,s,t-1);c[i][j]='x';c[j][i]='o';l=x(c,n,s,t-1);return w<l?w:l;}int main(){int n,a[6][6],s=0,t=0,i,j;scanf("%d\n",&n);for(i=0;i<n;i++){for(j=0;j<n;j++)a[i][j]=getchar(),a[i][j]-'-'||t++;getchar();}t/=2;for(j=0;j<n;j++){if(a[0][j]=='-'){a[0][j]='o';a[j][0]='x';t--;}if(a[0][j]=='o')s++;}printf("%d",x(a,n,s,t));return 0;}