結果

問題 No.471 直列回転機
ユーザー くれちー
提出日時 2016-12-21 23:53:16
言語 C90
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 1,077 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 25,704 KB
平均クエリ数 9096.70
最終ジャッジ日時 2024-07-16 11:54:16
合計ジャッジ時間 16,287 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29 RE * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", &m);
      |         ^~~~~~~~~~~~~~~
main.c:11:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         rep(i, m) scanf("%d %d", &x[i], &y[i]);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:18:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                 scanf("%d %d", &x_[i], &y_[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define min(a, b) (a < b ? a : b)

int main() {
	int m;
	scanf("%d", &m);
	
	static int x[50000], y[50000];
	int i;	
	rep(i, m) scanf("%d %d", &x[i], &y[i]);

	int x_[2], y_[2];

	rep(i, min(m, 2)) {
		printf("? %d %d\n", x[i], y[i]);
		fflush(stdout);
		scanf("%d %d", &x_[i], &y_[i]);
	}
	if (m <= 2) {
		puts("!");
		rep(i, min(m, 2)) printf("%d %d\n", x_[i], y_[i]);
		return 0;
	}

	int dx = x[1] - x[0];
	int dy = y[1] - y[0];	
	int dx_ = x_[1] - x_[0];
	int dy_ = y_[1] - y_[0];

	puts("!");

	rep(i, m) {
		int tx, ty;
		if ((dx == dx_) && (dy == dy_)) {
			tx = x_[0] + (x[i] - x[0]);
			ty = y_[0] + (y[i] - y[0]);
		}
		else if ((dx == -dx_) && (dy == -dy_)) {
			tx = x_[0] - (x[i] - x[0]);
			ty = y_[0] - (y[i] - y[0]);
		}
		else if ((dx == dy_) && (dy == dx_)) {
			tx = x_[0] + (y[i] - y[0]);
			ty = y_[0] + (x[i] - x[0]);
		}
		else if ((dx == -dy_) && (dy == -dx_)) {
			tx = x_[0] - (y[i] - y[0]);
			ty = y_[0] - (x[i] - x[0]);
		}
		else return 1;
		printf("%d %d\n", tx, ty);
	}

	return 0;
}
0