# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887161 | 2023-12-13T23:03:30 Z | Servant_of_the_Lord | Sirni (COCI17_sirni) | C++17 | 5000 ms | 607724 KB |
#include <bits/stdc++.h> #pragma GCC optimize("O3") #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 | 389 ms | 236792 KB | Output is correct |
2 | Correct | 1149 ms | 299576 KB | Output is correct |
3 | Correct | 398 ms | 237340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1124 ms | 372212 KB | Output is correct |
2 | Correct | 3355 ms | 583684 KB | Output is correct |
3 | Correct | 404 ms | 238544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 398 ms | 236880 KB | Output is correct |
2 | Correct | 277 ms | 236628 KB | Output is correct |
3 | Correct | 393 ms | 236888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1859 ms | 403932 KB | Output is correct |
2 | Correct | 3122 ms | 545560 KB | Output is correct |
3 | Correct | 3066 ms | 593080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 525 ms | 284500 KB | Output is correct |
2 | Correct | 2576 ms | 435644 KB | Output is correct |
3 | Correct | 2759 ms | 504560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2778 ms | 471324 KB | Output is correct |
2 | Correct | 2881 ms | 607724 KB | Output is correct |
3 | Correct | 1892 ms | 499316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1968 ms | 457104 KB | Output is correct |
2 | Correct | 3349 ms | 607456 KB | Output is correct |
3 | Correct | 2637 ms | 569768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1248 ms | 279888 KB | Output is correct |
2 | Execution timed out | 5130 ms | 553944 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1323 ms | 291784 KB | Output is correct |
2 | Execution timed out | 5070 ms | 600244 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 582 ms | 243540 KB | Output is correct |
2 | Execution timed out | 5127 ms | 502612 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |