제출 #890707

#제출 시각아이디문제언어결과실행 시간메모리
890707aykhnSirni (COCI17_sirni)C++17
98 / 140
1250 ms786432 KiB
#include <bits/stdc++.h> // author : aykhn using namespace std; typedef long long ll; #define pb push_back #define ins insert #define mpr make_pair #define all(v) v.begin(), v.end() #define bpc __builtin_popcountll #define pii pair<ll, ll> #define pll pair<ll, ll> #define fi first #define se second #define int ll #define infll 0x3F3F3F3F3F3F3F3F #define inf 0x3F3F3F3F struct DSU { vector<int> e; void init(int n) { e.assign(n + 1, -1); } int get(int x) { if (e[x] < 0) return x; return e[x] = get(e[x]); } int tog(int x, int y) { return get(x) == get(y); } int unite(int x, int y) { x = get(x); y = get(y); if (x == y) return 0; if (e[x] > e[y]) swap(x, y); e[x] += e[y]; e[y] = x; return 1; } }; const int MXN = 5e5 + 5; signed main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int n; cin >> n; int a[n + 1]; a[0] = 0; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); vector<array<int, 3>> e; for (int i = 1; i <= n; i++) { if (a[i] == a[i - 1]) continue; for (int j = a[i]; j <= a[n]; j += a[i]) { int ind = (j == a[i] ? upper_bound(a + 1, a + n + 1, j) - a : lower_bound(a + 1, a + n + 1, j) - a); if (ind > n) break; e.pb({a[ind] % a[i], i, ind}); j = a[ind]/a[i] * a[i]; } } sort(all(e)); int res = 0; DSU dsu; dsu.init(n); for (int i = 0; i < e.size(); i++) { if (dsu.unite(e[i][1], e[i][2])) res += e[i][0]; } cout << res << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

sirni.cpp: In function 'int main()':
sirni.cpp:77:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     for (int i = 0; i < e.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...