結果

問題 No.471 直列回転機
コンテスト
ユーザー tnakao0123
提出日時 2016-12-21 15:19:21
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 157 ms / 3,141 ms
コード長 1,279 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 622 ms
コンパイル使用メモリ 106,244 KB
実行使用メモリ 29,000 KB
平均クエリ数 19589.39
最終ジャッジ日時 2026-03-04 12:09:07
合計ジャッジ時間 7,185 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- 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