# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
782070 | 2023-07-13T15:14:30 Z | Ahmed57 | Sirni (COCI17_sirni) | C++17 | 3144 ms | 559996 KB |
//#pragma GCC optimize("Ofast,O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> using namespace std; //DSU int mn = 100001; int pr[100001]; int gs[100001]; int findleader(int x){ if(pr[x]==x){ return x; } return pr[x] = findleader(pr[x]); } bool mergegroup(int x,int y){ int led1 = findleader(x); int led2 = findleader(y); if(led1==led2)return 0; if(gs[led1]>gs[led2]){ pr[led2]=led1; gs[led1]+=gs[led2]; }else{ pr[led1]=led2; gs[led2]+=gs[led1]; } return 1; } vector<pair<int,int>> adj[10000001]; int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin>>n; set<int> s; int ma = 0; for(int i = 0;i<n;i++){ int x;cin>>x; s.insert(x); ma = max(ma,x); } assert(ma<=1e7); vector<int> arr; for(auto i:s)arr.push_back(i); n = arr.size(); for(int i = 0;i<n;i++)pr[i] = i , gs[i] = 1; for(int i = 0;i<n;i++){ int j = i+1; for(int e = arr[i];e<=ma;e+=arr[i]){ while(j<n&&arr[j]<e)j++; if(j<n)adj[arr[j]%arr[i]].push_back({i,j}); j++; } } long long all = 0; for(int i = 0;i<=1e7;i++){ for(int j = 0;j<adj[i].size();j++){ if(mergegroup(adj[i][j].first,adj[i][j].second))all+=i; } } cout<<all<<"\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 127 ms | 235352 KB | Output is correct |
2 | Correct | 137 ms | 237820 KB | Output is correct |
3 | Correct | 125 ms | 235392 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 141 ms | 235296 KB | Output is correct |
2 | Correct | 184 ms | 235920 KB | Output is correct |
3 | Correct | 129 ms | 235508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 124 ms | 235280 KB | Output is correct |
2 | Correct | 130 ms | 235248 KB | Output is correct |
3 | Correct | 127 ms | 235416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2206 ms | 250580 KB | Output is correct |
2 | Correct | 1909 ms | 277912 KB | Output is correct |
3 | Correct | 1512 ms | 254256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 179 ms | 237716 KB | Output is correct |
2 | Correct | 234 ms | 258896 KB | Output is correct |
3 | Correct | 1517 ms | 249476 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2318 ms | 262204 KB | Output is correct |
2 | Correct | 2121 ms | 293092 KB | Output is correct |
3 | Correct | 2092 ms | 254292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 399 ms | 240628 KB | Output is correct |
2 | Correct | 1940 ms | 286788 KB | Output is correct |
3 | Correct | 1632 ms | 253800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2199 ms | 254048 KB | Output is correct |
2 | Correct | 2652 ms | 466488 KB | Output is correct |
3 | Correct | 2179 ms | 257252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2265 ms | 253892 KB | Output is correct |
2 | Correct | 3144 ms | 559996 KB | Output is correct |
3 | Correct | 2086 ms | 261484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 220 ms | 238604 KB | Output is correct |
2 | Correct | 2541 ms | 554480 KB | Output is correct |
3 | Correct | 1677 ms | 255364 KB | Output is correct |