結果
問題 |
No.3184 Make Same
|
ユーザー |
|
提出日時 | 2025-06-20 22:02:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 353 ms / 2,000 ms |
コード長 | 784 bytes |
コンパイル時間 | 2,459 ms |
コンパイル使用メモリ | 197,384 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-06-20 22:03:05 |
合計ジャッジ時間 | 14,911 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26: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=] 26 | 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; if (u == 1) continue; 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; }