結果
| 問題 |
No.3184 Make Same
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-06-21 22:31:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 815 bytes |
| コンパイル時間 | 615 ms |
| コンパイル使用メモリ | 45,824 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-21 22:31:34 |
| 合計ジャッジ時間 | 15,726 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:33:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | for (int i = 0; i < n; i++) scanf("%d", as + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3184.cc: No.3184 Make Same - yukicoder
*/
#include<cstdio>
#include<algorithm>
#include<utility>
using namespace std;
/* constant */
const int MAX_N = 200000;
const int BN = 30;
/* typedef */
using pii = pair<int,int>;
/* global variables */
int as[MAX_N];
pii ops[BN];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", as + i);
int m = 0;
for (int i = BN - 1; i >= 0; i--) {
int r = 0;
while (r < n && ! ((as[r] >> i) & 1)) r++;
if (r < n) {
ops[m++] = {r, i};
for (int j = 0; j < r; j++) as[j] |= (1 << i);
sort(as, as + n);
}
}
printf("%d\n", m);
for (int i = 0; i < m; i++) {
auto [r, j] = ops[i];
printf("1 %d %d\n", r, 1 << j);
}
return 0;
}
tnakao0123