結果

問題 No.471 直列回転機
ユーザー tnakao0123
提出日時 2016-12-21 15:19:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 304 ms / 3,141 ms
コード長 1,279 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 83,160 KB
実行使用メモリ 25,808 KB
平均クエリ数 19589.39
最終ジャッジ日時 2024-06-11 10:29:28
合計ジャッジ時間 11,697 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 58
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void ask(int, int, int&, int&)’:
main.cpp:41:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |   scanf("%d%d", &xd, &yd);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:48:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |   scanf("%d", &m);
      |   ~~~~~^~~~~~~~~~
main.cpp:49:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |   for (int i = 0; i < m; i++) scanf("%d%d", xs + i, ys + i);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 471.cc: No.471 直列回転機 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_M = 50000;

/* typedef */

/* global variables */

int xs[MAX_M], ys[MAX_M];

/* subroutines */

void ask(int x, int y, int &xd, int &yd) {
  printf("? %d %d\n", x, y); fflush(stdout);
  scanf("%d%d", &xd, &yd);
}

/* main */

int main() {
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) scanf("%d%d", xs + i, ys + i);

  // x' = ax + by + c
  // y' = dx + ey + f
  int a, b, c, d, e, f;

  // (0, 0) -> (c, f)
  ask(0, 0, c, f);

  // (1, 0) -> (a + c, d + f)
  int ac, df;
  ask(1, 0, ac, df);
  a = ac - c;
  d = df - f;

  // (0, 1) -> (b + c, e + f);
  int bc, ef;
  ask(0, 1, bc, ef);
  b = bc - c;
  e = ef - f;

  putchar('!'); putchar('\n');
  for (int i = 0; i < m; i++) {
    int x = a * xs[i] + b * ys[i] + c;
    int y = d * xs[i] + e * ys[i] + f;
    printf("%d %d\n", x, y);
  }
  fflush(stdout);

  return 0;
}

0