結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー notetonousnotetonous
提出日時 2016-04-28 17:54:25
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 944 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:19:50
合計ジャッジ時間 1,245 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 AC 0 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 0 ms
5,376 KB
testcase_19 AC 0 ms
5,376 KB
testcase_20 AC 0 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 0 ms
5,376 KB
testcase_24 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:47:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |   for(i=0;i<3;i++)scanf("%d %d",&x[i],&y[i]);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#define MAX 4
int used[MAX];
int perm[MAX];
int x[MAX];
int y[MAX];
int flag=0;
int ansx,ansy;
void calc(){
  int i=0;
  int vx,vy,ux,uy;
  vx=x[perm[0]]-x[perm[1]];
  vy=y[perm[0]]-y[perm[1]];
  ux=x[perm[2]]-x[perm[1]];
  uy=y[perm[2]]-y[perm[1]];
  if(vx*ux+vy*uy==0 && vx*vx+vy*vy == ux*ux+uy*uy){
    ansx=x[perm[1]]+vx+ux;
    ansy=y[perm[1]]+vy+uy;
    flag=1;
  }
  
  //for(i=0;i<3;i++)printf("%d %d\n",x[perm[i]],y[perm[i]]);
  // printf("%d\n",vx*ux+vy*uy);
  //printf("%d %d %d %d\n",vx,vy,ux,uy);
  //printf("\n");
}
void perm1(int pos,int n){
  int i;
  if(pos==n){
    calc();
  return ;
  }
  for(i=0;i<n;i++){
    if(!used[i]){
      perm[pos]=i;
      used[i]=1;
      perm1(pos+1,n);
      used[i]=0;
    }
  }
  return ;
}

int main(){
  int i;
  for(i=0;i<3;i++)scanf("%d %d",&x[i],&y[i]);
  perm1(0,3);

  if(flag==0)printf("-1\n");
  else printf("%d %d\n",ansx,ansy);
  return 0;
}
0