結果

問題 No.3018 目隠し宝探し
ユーザー tsunamayo123
提出日時 2025-01-25 13:20:41
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 810 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 25,216 KB
実行使用メモリ 87,000 KB
最終ジャッジ日時 2025-01-25 22:44:45
合計ジャッジ時間 70,678 ms
ジャッジサーバーID
(参考情報)
judge4 / judge10
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1
other TLE * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:14: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |     int H,W; scanf("%d %d",&H,&W);
      |              ^~~~~~~~~~~~~~~~~~~~
main.c:6:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     int d1; scanf("%d",&d1);
      |             ^~~~~~~~~~~~~~~
main.c:8:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     int d2; scanf("%d",&d2);
      |             ^~~~~~~~~~~~~~~
main.c:27:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     int d3; scanf("%d",&d3);
      |             ^~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(){
    int H,W; scanf("%d %d",&H,&W);
    printf("? %d %d\n",1,1);
    int d1; scanf("%d",&d1);
    printf("? %d %d\n",H,W);
    int d2; scanf("%d",&d2);

    int D[2][2]={{-1,-1},{-1,-1}};
    int size=0;

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            int dist1=(i-1)*(i-1)+(j-1)*(j-1);
            int dist2=(i-H)*(i-H)+(j-W)*(j-W);
            if(dist1==d1 && dist2==d2){
                if(size>=2)return 1;
                D[size][0]=i;
                D[size][1]=j;
                size++;
            }
        }
    }

    printf("? %d %d\n",D[0][0],D[0][1]);
    int d3; scanf("%d",&d3);

    if(d3==0)printf("! %d %d\n",D[0][0],D[0][1]);
    else{
        if(size==1)return 1;
        printf("! %d %d\n",D[1][0],D[1][1]);
    }
    
    return 0;
}
0