# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887154 | 2023-12-13T22:41:05 Z | Servant_of_the_Lord | Sirni (COCI17_sirni) | C++17 | 1253 ms | 353584 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<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(i!=*s.begin())c=i*(*s.begin()); else c=i; if(v[i-1].empty()) { for(ll j=i-1;j<10'000'000;j+=c) { 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 306 ms | 236440 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 168 ms | 286968 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 272 ms | 236612 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 517 ms | 305784 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 131 ms | 254292 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 679 ms | 321616 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 544 ms | 353584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1010 ms | 255896 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1253 ms | 275536 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 396 ms | 239876 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |