結果

問題 No.471 直列回転機
ユーザー GrenacheGrenache
提出日時 2016-12-21 22:13:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 723 ms / 3,141 ms
コード長 4,521 bytes
コンパイル時間 3,874 ms
コンパイル使用メモリ 74,852 KB
実行使用メモリ 78,732 KB
平均クエリ数 19589.39
最終ジャッジ日時 2023-09-02 03:49:25
合計ジャッジ時間 30,082 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
68,060 KB
testcase_01 AC 139 ms
71,976 KB
testcase_02 AC 128 ms
70,984 KB
testcase_03 AC 140 ms
70,672 KB
testcase_04 AC 138 ms
71,464 KB
testcase_05 AC 162 ms
70,960 KB
testcase_06 AC 145 ms
70,348 KB
testcase_07 AC 163 ms
71,596 KB
testcase_08 AC 267 ms
73,084 KB
testcase_09 AC 262 ms
75,280 KB
testcase_10 AC 229 ms
74,432 KB
testcase_11 AC 381 ms
73,984 KB
testcase_12 AC 571 ms
74,620 KB
testcase_13 AC 588 ms
77,296 KB
testcase_14 AC 612 ms
75,272 KB
testcase_15 AC 723 ms
78,140 KB
testcase_16 AC 152 ms
70,056 KB
testcase_17 AC 140 ms
71,276 KB
testcase_18 AC 140 ms
69,792 KB
testcase_19 AC 143 ms
69,160 KB
testcase_20 AC 671 ms
78,340 KB
testcase_21 AC 301 ms
73,632 KB
testcase_22 AC 581 ms
74,492 KB
testcase_23 AC 570 ms
74,580 KB
testcase_24 AC 421 ms
75,752 KB
testcase_25 AC 301 ms
73,292 KB
testcase_26 AC 642 ms
78,336 KB
testcase_27 AC 416 ms
75,148 KB
testcase_28 AC 448 ms
73,904 KB
testcase_29 AC 486 ms
75,668 KB
testcase_30 AC 342 ms
74,944 KB
testcase_31 AC 650 ms
78,060 KB
testcase_32 AC 564 ms
77,032 KB
testcase_33 AC 469 ms
73,544 KB
testcase_34 AC 623 ms
78,732 KB
testcase_35 AC 317 ms
73,132 KB
testcase_36 AC 379 ms
75,452 KB
testcase_37 AC 255 ms
75,140 KB
testcase_38 AC 288 ms
75,388 KB
testcase_39 AC 356 ms
75,260 KB
testcase_40 AC 500 ms
75,056 KB
testcase_41 AC 638 ms
78,328 KB
testcase_42 AC 478 ms
75,208 KB
testcase_43 AC 610 ms
77,096 KB
testcase_44 AC 259 ms
72,960 KB
testcase_45 AC 475 ms
75,700 KB
testcase_46 AC 504 ms
73,632 KB
testcase_47 AC 598 ms
76,416 KB
testcase_48 AC 520 ms
76,824 KB
testcase_49 AC 504 ms
74,480 KB
testcase_50 AC 598 ms
78,676 KB
testcase_51 AC 367 ms
75,460 KB
testcase_52 AC 155 ms
72,064 KB
testcase_53 AC 159 ms
72,228 KB
testcase_54 AC 182 ms
70,656 KB
testcase_55 AC 332 ms
75,552 KB
testcase_56 AC 314 ms
76,148 KB
testcase_57 AC 282 ms
74,960 KB
testcase_58 AC 258 ms
75,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder471 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int m = sc.nextInt();

		int[] x = new int[m];
		int[] y = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		cmd("? 0 0");
		long t02 = sc.nextLong();
		long t12 = sc.nextLong();

		cmd("? 1 0");
		long t00 = sc.nextLong() - t02;
		long t10 = sc.nextLong() - t12;

		cmd("? 0 1");
		long t01 = sc.nextLong() - t02;
		long t11 = sc.nextLong() - t12;

		cmd("!");
		for (int i = 0; i < m; i++) {
			long rx = t00 * x[i] + t01 * y[i] + t02;
			long ry = t10 * x[i] + t11 * y[i] + t12;

			pr.printf("%d %d\n", rx, ry);
		}
		pr.flush();
	}

	private static void cmd(String s) {
		pr.println(s);
		pr.flush();
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		private boolean isPrintable(int ch) {
			return ch >= '!' && ch <= '~';
		}

		private boolean isCRLF(int ch) {
			return ch == '\n' || ch == '\r' || ch == -1;
		}

		private int nextPrintable() {
			try {
				int ch;
				while (!isPrintable(ch = br.read())) {
					if (ch == -1) {
						throw new NoSuchElementException();
					}
				}

				return ch;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		String next() {
			try {
				int ch = nextPrintable();
				StringBuilder sb = new StringBuilder();
				do {
					sb.appendCodePoint(ch);
				} while (isPrintable(ch = br.read()));

				return sb.toString();
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		int nextInt() {
			try {
				// parseInt from Integer.parseInt()
				boolean negative = false;
				int res = 0;
				int limit = -Integer.MAX_VALUE;
				int radix = 10;

				int fc = nextPrintable();
				if (fc < '0') {
					if (fc == '-') {
						negative = true;
						limit = Integer.MIN_VALUE;
					} else if (fc != '+') {
						throw new NumberFormatException();
					}
					fc = br.read();
				}
				int multmin = limit / radix;

				int ch = fc;
				do {
					int digit = ch - '0';
					if (digit < 0 || digit >= radix) {
						throw new NumberFormatException();
					}
					if (res < multmin) {
						throw new NumberFormatException();
					}
					res *= radix;
					if (res < limit + digit) {
						throw new NumberFormatException();
					}
					res -= digit;

				} while (isPrintable(ch = br.read()));

				return negative ? res : -res;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		long nextLong() {
			try {
				// parseLong from Long.parseLong()
				boolean negative = false;
				long res = 0;
				long limit = -Long.MAX_VALUE;
				int radix = 10;

				int fc = nextPrintable();
				if (fc < '0') {
					if (fc == '-') {
						negative = true;
						limit = Long.MIN_VALUE;
					} else if (fc != '+') {
						throw new NumberFormatException();
					}
					fc = br.read();
				}
				long multmin = limit / radix;

				int ch = fc;
				do {
					int digit = ch - '0';
					if (digit < 0 || digit >= radix) {
						throw new NumberFormatException();
					}
					if (res < multmin) {
						throw new NumberFormatException();
					}
					res *= radix;
					if (res < limit + digit) {
						throw new NumberFormatException();
					}
					res -= digit;

				} while (isPrintable(ch = br.read()));

				return negative ? res : -res;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		float nextFloat() {
			return Float.parseFloat(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				int ch;
				while (isCRLF(ch = br.read())) {
					if (ch == -1) {
						throw new NoSuchElementException();
					}
				}
				StringBuilder sb = new StringBuilder();
				do {
					sb.appendCodePoint(ch);
				} while (!isCRLF(ch = br.read()));

				return sb.toString();
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new NoSuchElementException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0