Submission #1057679

# Submission time Handle Problem Language Result Execution time Memory
1057679 2024-08-14T03:10:59 Z vjudge1 Sirni (COCI17_sirni) C++17
0 / 140
800 ms 104192 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];
    }
    sort(p+1,p+n+1);
    for (int i=1;i<=n;++i)
    {
        pa[i]=i;
        if (i!=1 && p[i]==p[i-1]) edge.push_back({0,{i,i-1}});
        else 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 (vec[hao].fi<2*p[i] && hao!=vec.size())
        {
            edge.push_back({vec[hao].fi%p[i],{i,vec[hao].se}});
        }
        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 (vec[hao].fi<(j+1)*p[i] && hao!=vec.size())
            {
            edge.push_back({vec[hao].fi%(p[i]*j),{i,vec[hao].se}});
            }
        }
    }
    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:46:38: 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]
   46 |         if (vec[hao].fi<2*p[i] && hao!=vec.size())
      |                                   ~~~^~~~~~~~~~~~
sirni.cpp:54: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]
   54 |             if (vec[hao].fi<(j+1)*p[i] && hao!=vec.size())
      |                                           ~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 320 ms 56232 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 8352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 800 ms 104192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 309 ms 15344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 222 ms 55976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 55828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 7504 KB Output isn't correct
2 Halted 0 ms 0 KB -