結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ripityripity
提出日時 2022-04-15 20:23:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,251 bytes
コンパイル時間 1,992 ms
コンパイル使用メモリ 80,280 KB
実行使用メモリ 64,212 KB
最終ジャッジ日時 2023-08-26 07:03:26
合計ジャッジ時間 16,797 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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];
        }
        
        pw.println(que.size());
        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;
        
    }
    
}
0