結果

問題 No.471 直列回転機
ユーザー uwiuwi
提出日時 2019-03-01 19:24:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,965 ms / 3,141 ms
コード長 2,181 bytes
コンパイル時間 3,821 ms
コンパイル使用メモリ 79,468 KB
実行使用メモリ 86,196 KB
平均クエリ数 19595.39
最終ジャッジ日時 2023-09-02 04:00:23
合計ジャッジ時間 69,039 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
72,208 KB
testcase_01 AC 185 ms
72,460 KB
testcase_02 AC 188 ms
72,748 KB
testcase_03 AC 183 ms
72,672 KB
testcase_04 AC 184 ms
72,348 KB
testcase_05 AC 273 ms
73,492 KB
testcase_06 AC 215 ms
73,304 KB
testcase_07 AC 257 ms
73,888 KB
testcase_08 AC 617 ms
77,668 KB
testcase_09 AC 610 ms
77,340 KB
testcase_10 AC 459 ms
76,424 KB
testcase_11 AC 1,177 ms
83,864 KB
testcase_12 AC 1,794 ms
84,228 KB
testcase_13 AC 1,785 ms
81,976 KB
testcase_14 AC 1,873 ms
81,972 KB
testcase_15 AC 1,965 ms
82,648 KB
testcase_16 AC 228 ms
73,136 KB
testcase_17 AC 185 ms
70,704 KB
testcase_18 AC 171 ms
72,508 KB
testcase_19 AC 189 ms
72,500 KB
testcase_20 AC 1,861 ms
83,668 KB
testcase_21 AC 679 ms
75,712 KB
testcase_22 AC 1,805 ms
84,224 KB
testcase_23 AC 1,763 ms
83,956 KB
testcase_24 AC 1,334 ms
84,168 KB
testcase_25 AC 614 ms
77,764 KB
testcase_26 AC 1,898 ms
84,264 KB
testcase_27 AC 1,319 ms
83,736 KB
testcase_28 AC 1,571 ms
83,796 KB
testcase_29 AC 1,612 ms
83,508 KB
testcase_30 AC 815 ms
77,536 KB
testcase_31 AC 1,881 ms
83,872 KB
testcase_32 AC 1,726 ms
81,944 KB
testcase_33 AC 1,603 ms
85,588 KB
testcase_34 AC 1,813 ms
81,696 KB
testcase_35 AC 728 ms
76,716 KB
testcase_36 AC 1,072 ms
79,096 KB
testcase_37 AC 539 ms
77,828 KB
testcase_38 AC 699 ms
77,116 KB
testcase_39 AC 940 ms
77,428 KB
testcase_40 AC 1,712 ms
83,772 KB
testcase_41 AC 1,927 ms
83,568 KB
testcase_42 AC 1,600 ms
83,620 KB
testcase_43 AC 1,852 ms
83,916 KB
testcase_44 AC 449 ms
77,456 KB
testcase_45 AC 1,585 ms
84,328 KB
testcase_46 AC 1,731 ms
83,748 KB
testcase_47 AC 1,862 ms
83,492 KB
testcase_48 AC 1,745 ms
83,948 KB
testcase_49 AC 1,794 ms
86,196 KB
testcase_50 AC 1,843 ms
84,344 KB
testcase_51 AC 1,082 ms
79,320 KB
testcase_52 AC 252 ms
73,788 KB
testcase_53 AC 259 ms
73,444 KB
testcase_54 AC 299 ms
73,636 KB
testcase_55 AC 789 ms
77,084 KB
testcase_56 AC 659 ms
77,520 KB
testcase_57 AC 520 ms
77,672 KB
testcase_58 AC 459 ms
76,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package adv2016;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class N471_2 {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	// (0 1)(x-a)  +(a)
	// (-1 0)(y-b)  (b)
	
	static long[][][] ret = new long[3][3][];
	
	static void solve()
	{
		int m = ni();
		int[][] co = new int[m][];
		for(int i = 0;i < m;i++) {
			co[i] = new int[] {ni(), ni()};
		}
		
		for(int i = 0;i < 3;i++) {
			for(int j = 0;j < 3;j++) {
				out.println("? " + i + " " + j);
				out.flush();
				long x = nl(), y = nl();
				ret[i][j] = new long[] {x, y};
			}
		}
		
		int[][] M = {
				{0, 1},
				{-1, 0}
		};
		
		int[][] A = {
				{1, 0},
				{0, 1}
		};
		
		outer:
		for(int k = 0;k < 4;k++) {
			A = mul(A, M);
			// A[0][0]*x + A[0][1]*y + s = X
			// A[1][0]*x + A[1][1]*y + t = Y
			long S = ret[0][0][0], T = ret[0][0][1];
			for(int i = 0;i < 3;i++) {
				for(int j = 0;j < 3;j++) {
					if(A[0][0] * i + A[0][1] * j + S != ret[i][j][0])continue outer;
					if(A[1][0] * i + A[1][1] * j + T != ret[i][j][1])continue outer;
				}
			}
			
			out.println("!");
			for(int[] v : co) {
				out.println(
						(A[0][0] * v[0] + A[0][1] * v[1] + S) + " " +
						(A[1][0] * v[0] + A[1][1] * v[1] + T)
						);
				out.flush();
			}
			return;
		}
		
		// (1,0) -> (0,-1)
		
		// (0 1 x)
		// (-1 0 y)
		// (0 0 1)
	}
	
	public static int[][] mul(int[][] A, int[][] B)
	{
		assert A[0].length == B.length;
		int m = A.length;
		int n = A[0].length;
		int o = B[0].length;
		int[][] C = new int[m][o];
		for(int i = 0;i < m;i++){
			for(int k = 0;k < n;k++){
				for(int j = 0;j < o;j++){
					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		return C;
	}

	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0