제출 #715211

#제출 시각아이디문제언어결과실행 시간메모리
715211murad_2005Sirni (COCI17_sirni)C++14
42 / 140
803 ms786432 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int, int> #define piii pair<int, pii> #define pllll pair<ll, ll> #define plli pair<ll, int> #define vi vector<int> #define vvi vector<vector<int>> #define pb push_back #define eb emplace_back #define all(v) v.begin(), v.end() #define size(v) v.size() #define INF 1e9 #define f first #define s second #define ln "\n" using namespace std; const int up = 1e5 + 5; int sz[up], parent[up]; void make_set(int u){ sz[u] = 1, parent[u] = u; } int find_set(int u){ if(u == parent[u]) return u; return parent[u] = find_set(parent[u]); } void union_set(int u, int v){ int a = find_set(u); int b = find_set(v); if(a != b){ if(sz[a] < sz[b]){ swap(a, b); } parent[b] = a; sz[a] += b; } } void solve(){ int n; cin >> n; vector<int>p(n + 1); for(int i = 1; i <= n; ++i){ cin >> p[i]; make_set(i); } vector<piii>edges; for(int i = 1; i <= n; ++i){ for(int j = 1; j <= n; j++){ if(i != j){ int val = min(p[i] % p[j], p[j] % p[i]); edges.pb({val, {i, j}}); } } } sort(all(edges)); ll Res = 0; for(int i = 0; i < size(edges); ++i){ int u = edges[i].s.f; int v = edges[i].s.s; int val = edges[i].f; if(find_set(u) != find_set(v)){ Res += val; union_set(u, v); } } cout << Res << "\n"; } int main(){ int t; t = 1; // cin >> t; while(t--){ solve(); } return 0; }

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

sirni.cpp: In function 'void solve()':
sirni.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i = 0; i < size(edges); ++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...