結果
| 問題 |
No.355 数当てゲーム(2)
|
| コンテスト | |
| ユーザー |
kapo
|
| 提出日時 | 2016-05-07 14:59:54 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 1,318 bytes |
| コンパイル時間 | 947 ms |
| コンパイル使用メモリ | 22,528 KB |
| 実行使用メモリ | 25,592 KB |
| 平均クエリ数 | 25.46 |
| 最終ジャッジ日時 | 2024-07-16 23:41:28 |
| 合計ジャッジ時間 | 4,220 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 |
コンパイルメッセージ
main.c: In function ‘perm’:
main.c:12:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d %d", &x, &y);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c: In function ‘main’:
main.c:36:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%d %d", &x, &y);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:52:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
52 | scanf("%d %d", &x, &y);
| ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int b[4], p[4], p2[4], used[4], f=0;
void perm( int node)
{
if( node == 4 ) {
if( !f ) {
int i, x, y;
printf("%d %d %d %d\n", b[ p[0] ], b[ p[1] ], b[ p[2] ], b[ p[3] ]);
fflush(stdout);
scanf("%d %d", &x, &y);
if( x == 4 ) f = 1;
}
} else {
int i;
for( i = 0; i < 4; i++) {
if( !used[i] ) {
used[i] = 1;
p[node] = i;
perm(node+1);
used[i] = 0;
}
}
}
}
int main(void)
{
int i, j, k, a[4]={9,0,1,2}, x, y, xy=0, bxy=0, bcnt=0;
while( bcnt != 4) {
printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]);
fflush(stdout);
scanf("%d %d", &x, &y);
if(x == 4) return 0;
xy = x+y;
for( j = 0; j < bcnt; j++) {
for( k = 0; k < 4; k++) if( a[k] == b[j] ) xy--;
}
int cnt = 0, s[10]={};
while( cnt < 10 ) {
for( i = 0; i < 4; i++) {
a[i] = (cnt+i) % 10;
}
printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]);
fflush(stdout);
scanf("%d %d", &x, &y);
if(x == 4) return 0;
bxy = xy;
xy = x+y;
for( j = 0; j < bcnt; j++) {
for( k = 0; k < 4; k++) if( a[k] == b[j] ) xy--;
}
if( xy > bxy ) {
s[ (cnt+3) % 10] = 1;
} else if( xy < bxy ) {
s[ (cnt+9) % 10] = 1;
}
cnt++;
}
for( i = 0; i < 10; i++) {
if( s[i] ) {
b[bcnt] = i;
bcnt++;
}
}
}
perm(0);
return 0;
}
kapo