# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887162 | 2023-12-13T23:05:35 Z | Servant_of_the_Lord | Sirni (COCI17_sirni) | C++17 | 5000 ms | 607804 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<pair<ll,ll>>s; for(ll i=0;i<x;i++) { cin>>y; s.insert({y,i}); } vector<vector<ll>>v(10'000'000); for(pair<ll,ll> i:s) { if(v[i.first-1].empty()) { for(ll j=i.first-1;j<10'000'000;j+=i.first) { v[j].push_back(i.second); } } } 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(a),b=g(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<pair<ll,ll>>e; for(pair<ll,ll> j:s) { for(ll k=0;k<v[j.first-i-1].size();k++) { if(u(j.second,v[j.first-i-1][k])) { a+=i; } } if(j.first-i-1==0||t[j.first-i-1])e.push_back(j); t[j.first-i-1]=1; } for(auto j:e)s.erase(j); if(s.empty())break; } cout<<a<<'\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 569 ms | 236728 KB | Output is correct |
2 | Correct | 1364 ms | 299584 KB | Output is correct |
3 | Correct | 537 ms | 237264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 681 ms | 372328 KB | Output is correct |
2 | Correct | 3181 ms | 583468 KB | Output is correct |
3 | Correct | 569 ms | 238392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 545 ms | 236492 KB | Output is correct |
2 | Correct | 302 ms | 236392 KB | Output is correct |
3 | Correct | 534 ms | 236784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1518 ms | 403816 KB | Output is correct |
2 | Correct | 2416 ms | 545556 KB | Output is correct |
3 | Correct | 2616 ms | 593228 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 371 ms | 284396 KB | Output is correct |
2 | Correct | 2360 ms | 435564 KB | Output is correct |
3 | Correct | 2154 ms | 504660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2280 ms | 471344 KB | Output is correct |
2 | Correct | 2557 ms | 607604 KB | Output is correct |
3 | Correct | 1651 ms | 499428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1672 ms | 456980 KB | Output is correct |
2 | Correct | 2715 ms | 607804 KB | Output is correct |
3 | Correct | 2287 ms | 569836 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1705 ms | 279996 KB | Output is correct |
2 | Execution timed out | 5072 ms | 554088 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1711 ms | 291896 KB | Output is correct |
2 | Execution timed out | 5028 ms | 599884 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 729 ms | 243700 KB | Output is correct |
2 | Execution timed out | 5080 ms | 502748 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |