結果
問題 | No.1896 Arrays and XOR Procedure 2 |
ユーザー | tenten |
提出日時 | 2022-09-08 13:07:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 2,403 bytes |
コンパイル時間 | 1,939 ms |
コンパイル使用メモリ | 77,740 KB |
実行使用メモリ | 52,368 KB |
最終ジャッジ日時 | 2024-05-03 08:13:07 |
合計ジャッジ時間 | 8,405 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
49,892 KB |
testcase_01 | AC | 50 ms
50,440 KB |
testcase_02 | AC | 48 ms
50,028 KB |
testcase_03 | AC | 88 ms
51,800 KB |
testcase_04 | AC | 111 ms
52,116 KB |
testcase_05 | AC | 110 ms
52,028 KB |
testcase_06 | AC | 102 ms
51,916 KB |
testcase_07 | AC | 108 ms
52,240 KB |
testcase_08 | AC | 107 ms
51,976 KB |
testcase_09 | AC | 101 ms
52,180 KB |
testcase_10 | AC | 103 ms
51,936 KB |
testcase_11 | AC | 102 ms
52,056 KB |
testcase_12 | AC | 93 ms
51,792 KB |
testcase_13 | AC | 93 ms
51,720 KB |
testcase_14 | AC | 103 ms
51,896 KB |
testcase_15 | AC | 95 ms
51,688 KB |
testcase_16 | AC | 89 ms
51,740 KB |
testcase_17 | AC | 87 ms
51,940 KB |
testcase_18 | AC | 102 ms
52,220 KB |
testcase_19 | AC | 81 ms
51,536 KB |
testcase_20 | AC | 105 ms
52,044 KB |
testcase_21 | AC | 69 ms
51,488 KB |
testcase_22 | AC | 104 ms
52,232 KB |
testcase_23 | AC | 108 ms
52,068 KB |
testcase_24 | AC | 105 ms
51,956 KB |
testcase_25 | AC | 98 ms
52,368 KB |
testcase_26 | AC | 104 ms
52,108 KB |
testcase_27 | AC | 103 ms
52,216 KB |
testcase_28 | AC | 85 ms
51,672 KB |
testcase_29 | AC | 109 ms
51,924 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] countsA = new int[n]; int maxA = 0; int aIdx = 0; for (int i = 0; i < n; i++) { countsA[i] = getCount(sc.nextInt()); if (maxA < countsA[i]) { maxA = countsA[i]; aIdx = i; } } int[] countsB = new int[n]; int maxB = 0; int bIdx = 0; for (int i = 0; i < n; i++) { countsB[i] = getCount(sc.nextInt()); if (maxB < countsB[i]) { maxB = countsB[i]; bIdx = i; } } int ans = 0; StringBuilder sb = new StringBuilder(); if (maxA < maxB) { sb.append("1 1 ").append(bIdx + 1).append("\n"); ans++; maxA = maxB; aIdx = 0; countsA[0] = maxB; } for (int i = 0; i < n; i++) { if (countsB[i] < maxA) { sb.append("2 ").append(aIdx + 1).append(" ").append(i + 1).append("\n"); ans++; } } for (int i = 0; i < n; i++) { if (countsA[i] == maxA) { sb.append("1 ").append(i + 1).append(" 1\n"); ans++; } } System.out.println(ans); System.out.print(sb); } static int getCount(int x) { int count = 0; while (x > 0) { count++; x >>= 1; } return count; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }