結果
| 問題 |
No.3184 Make Same
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-20 22:01:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 754 bytes |
| コンパイル時間 | 1,928 ms |
| コンパイル使用メモリ | 201,152 KB |
| 実行使用メモリ | 7,888 KB |
| 最終ジャッジ日時 | 2025-06-20 22:01:21 |
| 合計ジャッジ時間 | 15,255 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<std::array<int, 3> >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
25 | printf("%d\n", ans.size());
| ~^ ~~~~~~~~~~
| | |
| int std::vector<std::array<int, 3> >::size_type {aka long unsigned int}
| %ld
main.cpp:15:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | for (int i = 1; i < n + 1; i++) scanf("%d", w + i);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2000008, MOD = 998244353, INF = 0x3f3f3f3f;
ll res;
int n, m, cnt, w[N], p[N];
int f[N];
int main() {
cin >> n;
for (int i = 1; i < n + 1; i++) scanf("%d", w + i);
int sum = 0;
vector<array<int, 3> > ans;
for (int i = 29; i >= 0; i--) {
sum += 1 << i;
int u = lower_bound(w + 1, w + n + 1, sum) - w;
ans.push_back({1, u - 1, 1 << i});
for (int j = 1; j < u; j++) w[j] += 1 << i;
sort(w + 1, w + n + 1);
}
printf("%d\n", ans.size());
for (auto [a, b, c] : ans) printf("%d %d %d\n", a, b, c);;
for (int i = 2; i < n + 1; i++) assert(w[i] == w[i - 1]);
return 0;
}