結果
問題 |
No.1896 Arrays and XOR Procedure 2
|
ユーザー |
![]() |
提出日時 | 2022-04-15 20:22:30 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,219 bytes |
コンパイル時間 | 2,972 ms |
コンパイル使用メモリ | 80,424 KB |
実行使用メモリ | 49,080 KB |
最終ジャッジ日時 | 2024-12-24 22:20:29 |
合計ジャッジ時間 | 15,230 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 27 |
ソースコード
import java.util.*; import java.io.*; public class Main { public static Scanner sc = new Scanner(System.in); public static PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args) { int N = sc.nextInt(); int[] a = new int[N]; int[] b = new int[N]; int[] x = new int[N]; int[] y = new int[N]; int xmax = -1; int ymax = -1; int p = 0; int q = 0; LinkedList<Tuple> que = new LinkedList<>(); for( int i = 0; i < N; i++ ) { a[i] = sc.nextInt(); while( (a[i]>>x[i]) > 0 ) x[i]++; xmax = Math.max(xmax,x[i]); } for( int i = 0; i < N; i++ ) { b[i] = sc.nextInt(); while( (b[i]>>y[i]) > 0 ) y[i]++; ymax = Math.max(ymax,y[i]); } if( xmax >= ymax ) { for( int i = 0; i < N; i++ ) { if( x[i] == xmax ) p = i; } for( q = 0; q < N; q++ ) { if( y[q] < x[p] ) { b[q] = a[p]^b[q]; que.offer(new Tuple(2,p+1,q+1)); } } for( p = 0; p < N; p++ ) { if( x[p] == xmax ) { a[p] = a[p]^b[0]; que.offer(new Tuple(1,p+1,1)); } } }else { for( int i = 0; i < N; i++ ) { if( y[i] == ymax ) q = i; } que.offer(new Tuple(1,1,q+1)); a[0] = a[0]^b[q]; for( q = 0; q < N; q++ ) { if( y[q] < ymax ) { b[q] = a[0]^b[q]; que.offer(new Tuple(2,1,q+1)); } } que.offer(new Tuple(1,1,1)); a[0] = a[0]^b[0]; } for( Tuple t : que ) { pw.println(t.a+" "+t.b+" "+t.c); } pw.println(); pw.flush(); } } class Tuple { int a, b, c; public Tuple(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } }