# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887163 | 2023-12-13T23:07:16 Z | Servant_of_the_Lord | Sirni (COCI17_sirni) | C++17 | 5000 ms | 607900 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}); } 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 | 279 ms | 236632 KB | Output is correct |
2 | Correct | 993 ms | 299360 KB | Output is correct |
3 | Correct | 281 ms | 237148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 667 ms | 372308 KB | Output is correct |
2 | Correct | 2778 ms | 583504 KB | Output is correct |
3 | Correct | 294 ms | 238420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 280 ms | 236544 KB | Output is correct |
2 | Correct | 148 ms | 236636 KB | Output is correct |
3 | Correct | 274 ms | 236880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1423 ms | 403972 KB | Output is correct |
2 | Correct | 2356 ms | 545664 KB | Output is correct |
3 | Correct | 2513 ms | 593160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 334 ms | 284244 KB | Output is correct |
2 | Correct | 2229 ms | 435720 KB | Output is correct |
3 | Correct | 2092 ms | 504544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2245 ms | 471380 KB | Output is correct |
2 | Correct | 2356 ms | 607820 KB | Output is correct |
3 | Correct | 1553 ms | 499728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1559 ms | 457476 KB | Output is correct |
2 | Correct | 2660 ms | 607900 KB | Output is correct |
3 | Correct | 2157 ms | 569968 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1018 ms | 279864 KB | Output is correct |
2 | Correct | 4857 ms | 554004 KB | Output is correct |
3 | Correct | 1127 ms | 291668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1093 ms | 291928 KB | Output is correct |
2 | Execution timed out | 5052 ms | 600256 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 462 ms | 243800 KB | Output is correct |
2 | Correct | 4658 ms | 503028 KB | Output is correct |
3 | Correct | 2355 ms | 578444 KB | Output is correct |