結果
問題 | No.1059 素敵な集合 |
ユーザー | 00 Sakuda |
提出日時 | 2024-03-31 06:58:39 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 404 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 2,389 ms |
コンパイル使用メモリ | 216,492 KB |
実行使用メモリ | 69,640 KB |
最終ジャッジ日時 | 2024-03-31 06:58:44 |
合計ジャッジ時間 | 4,977 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 404 ms
69,640 KB |
testcase_02 | AC | 21 ms
8,140 KB |
testcase_03 | AC | 2 ms
6,676 KB |
testcase_04 | AC | 1 ms
6,676 KB |
testcase_05 | AC | 2 ms
6,676 KB |
testcase_06 | AC | 16 ms
8,140 KB |
testcase_07 | AC | 17 ms
8,140 KB |
testcase_08 | AC | 24 ms
8,140 KB |
testcase_09 | AC | 6 ms
6,676 KB |
testcase_10 | AC | 49 ms
12,284 KB |
testcase_11 | AC | 17 ms
8,140 KB |
testcase_12 | AC | 9 ms
6,676 KB |
testcase_13 | AC | 40 ms
12,284 KB |
testcase_14 | AC | 2 ms
6,676 KB |
testcase_15 | AC | 89 ms
20,480 KB |
testcase_16 | AC | 21 ms
8,140 KB |
testcase_17 | AC | 18 ms
8,140 KB |
testcase_18 | AC | 10 ms
6,676 KB |
testcase_19 | AC | 374 ms
69,640 KB |
testcase_20 | AC | 354 ms
69,640 KB |
testcase_21 | AC | 75 ms
20,480 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> #include <atcoder/dsu> using namespace std; using namespace atcoder; using ll = long long; using mint = modint; using edge = pair<ll, pair<int, int>>; int main() { vector<edge> ED; int L, R;cin >> L >> R; int N = R - L + 1; for (int l = L;l < R;l++) { ED.push_back({1, {l - L, l + 1 - L}}); int now = 2 * l; while (now <= R) { ED.push_back({0LL, {l - L, now - L}}); now += l; } } sort(ED.begin(), ED.end()); dsu uf(N); ll ans = 0; for (auto ed : ED) { int a = ed.second.first;int b = ed.second.second; if (!uf.same(a, b)) { uf.merge(a, b); ans += ed.first; } } cout << ans << endl; }