Submission #1057665

# Submission time Handle Problem Language Result Execution time Memory
1057665 2024-08-14T03:04:59 Z vjudge1 Sirni (COCI17_sirni) C++17
0 / 140
5000 ms 402268 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define fi first
#define se second
const ll mod=1e9+7;
ll n,p[100005],ketqua;
int pa[100005];
map<pair<int,int>,int> siuu;
int find_pa(int u)
{
    if (pa[u]==u) return u;
    return pa[u]=find_pa(pa[u]);
}
void Merge(int u,int v,int x)
{
    u=find_pa(u);
    v=find_pa(v);
    if (v==u) return;
    ketqua+=x;
    pa[u]=v;
}
vector<pair<int,int>> vec;
vector<pair<int,pair<int,int>>> edge;
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;++i)
    {
        cin>>p[i];
        pa[i]=i;
        vec.push_back({p[i],i});
    }
    sort(vec.begin(),vec.end());
    for (int i=1;i<=n;++i)
    {
        int hao=upper_bound(vec.begin(),vec.end(),make_pair(p[i],0ll))-vec.begin();
        if (!siuu[{i,vec[hao].se}] && hao!=vec.size())
        {
            edge.push_back({vec[hao].fi%p[i],{i,vec[hao].se}});
            siuu[{i,vec[hao].se}]=1;
            siuu[{vec[hao].se,i}]=1;
        }
        for (int j=2;j*p[i]<=10000000;++j)
        {
            int hao=lower_bound(vec.begin(),vec.end(),make_pair(p[i]*j,0ll))-vec.begin();
            //edge.push_back({vec[hao].fi%(p[i]*j),{i,vec[hao].se}});
            if (!siuu[{i,vec[hao].se}] && hao!=vec.size())
            {
            edge.push_back({vec[hao].fi%(p[i]*j),{i,vec[hao].se}});
            siuu[{i,vec[hao].se}]=1;
            siuu[{vec[hao].se,i}]=1;
            }
        }
    }
    sort(edge.begin(),edge.end());
    for (auto it: edge)
    {
        Merge(it.se.fi,it.se.se,it.fi);
        //cout<<it.fi<<'\n';
    }
    cout<<ketqua;
}

Compilation message

sirni.cpp:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main()
      | ^~~~
sirni.cpp: In function 'int main()':
sirni.cpp:41:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (!siuu[{i,vec[hao].se}] && hao!=vec.size())
      |                                       ~~~^~~~~~~~~~~~
sirni.cpp:51:46: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             if (!siuu[{i,vec[hao].se}] && hao!=vec.size())
      |                                           ~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1754 ms 159124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 152 ms 23680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5068 ms 402268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1149 ms 58852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1650 ms 180236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1595 ms 179076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 145 ms 27452 KB Output isn't correct
2 Halted 0 ms 0 KB -