# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
887140 | 2023-12-13T21:15:01 Z | Servant_of_the_Lord | Sirni (COCI17_sirni) | C++17 | 5000 ms | 611504 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,sse4") #define ll long long using namespace std; main() { ios_base::sync_with_stdio(false); cin.tie(0); ll x,y,z,a,b,c; cin>>x; set<ll>s; map<ll,ll>m; for(ll i=0;i<x;i++) { cin>>y; s.insert(y); m[y]=i; } vector<vector<ll>>v(10'000'000); for(ll i:s) { if(v[i-1].empty()) { for(ll j=i-1;j<10'000'000;j+=i) { v[j].push_back(i); } } } vector<ll>w(x,-1); function<ll(ll)>g=[&](ll a){return w[a]<0?a:w[a]=g(w[a]);}; function<bool(ll,ll)>u=[&](ll a,ll b) { a=g(m[a]),b=g(m[b]); if(a==b)return false; if(w[a]>w[b])swap(a,b); w[a]+=w[b]; w[b]=a; return true; }; a=0; bitset<10'000'000>t; for(ll i=0;i<10'000'000;i++) { vector<ll>e; for(ll j:s) { for(ll k:v[j-i-1]) { if(u(j,k)) { a+=i; } } if(j-i-1==0||t[j-i-1])e.push_back(j); t[j-i-1]=1; } for(ll j:e)s.erase(j); if(s.empty())break; } cout<<a<<'\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 574 ms | 236624 KB | Output is correct |
2 | Correct | 1631 ms | 299468 KB | Output is correct |
3 | Correct | 565 ms | 237144 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 682 ms | 372408 KB | Output is correct |
2 | Correct | 4049 ms | 583588 KB | Output is correct |
3 | Correct | 588 ms | 238424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 546 ms | 236624 KB | Output is correct |
2 | Correct | 325 ms | 236624 KB | Output is correct |
3 | Correct | 547 ms | 236884 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1753 ms | 408112 KB | Output is correct |
2 | Correct | 2770 ms | 549312 KB | Output is correct |
3 | Correct | 2855 ms | 595104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 408 ms | 284908 KB | Output is correct |
2 | Correct | 2465 ms | 428368 KB | Output is correct |
3 | Correct | 2329 ms | 507004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2645 ms | 475436 KB | Output is correct |
2 | Correct | 2803 ms | 611504 KB | Output is correct |
3 | Correct | 1869 ms | 503172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1617 ms | 458336 KB | Output is correct |
2 | Correct | 3063 ms | 608848 KB | Output is correct |
3 | Correct | 2451 ms | 572196 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2246 ms | 284624 KB | Output is correct |
2 | Execution timed out | 5031 ms | 558440 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2499 ms | 296784 KB | Output is correct |
2 | Execution timed out | 5023 ms | 602388 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 840 ms | 244600 KB | Output is correct |
2 | Execution timed out | 5038 ms | 503888 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |