結果
問題 | No.1896 Arrays and XOR Procedure 2 |
ユーザー | tenten |
提出日時 | 2022-09-08 13:07:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 2,403 bytes |
コンパイル時間 | 2,270 ms |
コンパイル使用メモリ | 77,820 KB |
実行使用メモリ | 52,312 KB |
最終ジャッジ日時 | 2024-11-24 06:30:09 |
合計ジャッジ時間 | 8,478 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
50,384 KB |
testcase_01 | AC | 50 ms
50,428 KB |
testcase_02 | AC | 49 ms
50,072 KB |
testcase_03 | AC | 86 ms
51,876 KB |
testcase_04 | AC | 108 ms
52,100 KB |
testcase_05 | AC | 105 ms
51,980 KB |
testcase_06 | AC | 94 ms
51,948 KB |
testcase_07 | AC | 108 ms
52,304 KB |
testcase_08 | AC | 98 ms
51,692 KB |
testcase_09 | AC | 100 ms
51,972 KB |
testcase_10 | AC | 100 ms
52,096 KB |
testcase_11 | AC | 102 ms
51,600 KB |
testcase_12 | AC | 107 ms
51,940 KB |
testcase_13 | AC | 88 ms
51,836 KB |
testcase_14 | AC | 102 ms
51,848 KB |
testcase_15 | AC | 105 ms
52,180 KB |
testcase_16 | AC | 92 ms
51,712 KB |
testcase_17 | AC | 102 ms
51,696 KB |
testcase_18 | AC | 88 ms
52,120 KB |
testcase_19 | AC | 74 ms
51,556 KB |
testcase_20 | AC | 101 ms
52,312 KB |
testcase_21 | AC | 70 ms
51,420 KB |
testcase_22 | AC | 108 ms
52,216 KB |
testcase_23 | AC | 95 ms
52,076 KB |
testcase_24 | AC | 105 ms
52,048 KB |
testcase_25 | AC | 96 ms
52,248 KB |
testcase_26 | AC | 104 ms
51,832 KB |
testcase_27 | AC | 107 ms
52,296 KB |
testcase_28 | AC | 85 ms
51,668 KB |
testcase_29 | AC | 106 ms
52,008 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(); } }