# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887160 | 2023-12-13T23:01:52 Z | Servant_of_the_Lord | Sirni (COCI17_sirni) | C++17 | 5000 ms | 607848 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}); } array<vector<ll>,10'000'000>v; 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 | 664 ms | 236716 KB | Output is correct |
2 | Correct | 1498 ms | 299576 KB | Output is correct |
3 | Correct | 665 ms | 237396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 877 ms | 372344 KB | Output is correct |
2 | Correct | 3366 ms | 583896 KB | Output is correct |
3 | Correct | 686 ms | 238588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 663 ms | 236560 KB | Output is correct |
2 | Correct | 404 ms | 236620 KB | Output is correct |
3 | Correct | 673 ms | 236884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1665 ms | 404260 KB | Output is correct |
2 | Correct | 2666 ms | 546432 KB | Output is correct |
3 | Correct | 2846 ms | 593752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 503 ms | 284420 KB | Output is correct |
2 | Correct | 2592 ms | 435748 KB | Output is correct |
3 | Correct | 2392 ms | 504856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2524 ms | 471924 KB | Output is correct |
2 | Correct | 2711 ms | 607616 KB | Output is correct |
3 | Correct | 1900 ms | 499440 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1784 ms | 456996 KB | Output is correct |
2 | Correct | 3015 ms | 607848 KB | Output is correct |
3 | Correct | 2502 ms | 570076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1782 ms | 279892 KB | Output is correct |
2 | Execution timed out | 5100 ms | 553952 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1829 ms | 291752 KB | Output is correct |
2 | Execution timed out | 5043 ms | 599908 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 937 ms | 243632 KB | Output is correct |
2 | Execution timed out | 5054 ms | 502812 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |