Submission #986087

# Submission time Handle Problem Language Result Execution time Memory
986087 2024-05-19T17:49:37 Z alexdd ICC (CEOI16_icc) C++17
61 / 100
116 ms 852 KB
#include "icc.h"
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
vector<int> comps[105];
int unde[105];
vector<int> ord,ord2;
int aska[105],askb[105],sa,sb;
int wirtz(int poz)
{
    sa=sb=0;
    for(int i=0;i<=poz;i++)
        for(auto x:comps[ord[i]])
            aska[sa++]=x;
    for(int i=poz+1;i<ord.size();i++)
        for(auto x:comps[ord[i]])
            askb[sb++]=x;
    return query(sa,sb,aska,askb);
}
int boniface(int c1, int poz1, int c2)
{
    sa=sb=0;
    for(int i=0;i<=poz1;i++)
        aska[sa++]=comps[c1][i];
    for(auto x:comps[c2])
        askb[sb++]=x;
    return query(sa,sb,aska,askb);
}
int frimpong(int le1, int ri1, int le2, int ri2)
{
    sa=sb=0;
    for(int i=le1;i<=ri1;i++)
        aska[sa++]=ord2[i];
    for(int i=le2;i<=ri2;i++)
        askb[sb++]=ord2[i];
    return query(sa,sb,aska,askb);
}
void run(int N)
{
    n=N;
    for(int i=1;i<=n;i++)
    {
        ord.push_back(i);
        comps[i].push_back(i);
        unde[i]=i;
    }
    for(int pas=1;pas<n;pas++)
    {
        int cate=0;
        do
        {
            cate++;
            random_shuffle(ord.begin(),ord.end());
        }while(cate<=20 && !wirtz((int)ord.size()/2-1));
        ord2.clear();
        for(auto c:ord)
        {
            random_shuffle(comps[c].begin(),comps[c].end());
            for(auto x:comps[c])
                ord2.push_back(x);
        }
        int aux=0;
        for(int i=0;i<=(int)ord.size()/2-1;i++)
            aux += (int)comps[ord[i]].size();
        int st,dr,ans;
        st=aux;
        dr=(int)ord2.size()-2;
        ans=(int)ord2.size()-1;
        while(st<=dr)
        {
            int mij=(st+dr)/2;
            if(frimpong(0,aux-1,aux,mij))
            {
                ans=mij;
                dr=mij-1;
            }
            else
                st=mij+1;
        }
        int vri = ord2[ans];

        st=0;
        dr=aux-2;
        ans=aux-1;
        while(st<=dr)
        {
            int mij=(st+dr)/2;
            if(frimpong(0,mij,aux,(int)ord2.size()-1))
            {
                ans=mij;
                dr=mij-1;
            }
            else
                st=mij+1;
        }
        int vle = ord2[ans];

        setRoad(vle,vri);

        int cle=unde[vle],cri=unde[vri];
        for(auto x:comps[cri])
        {
            comps[cle].push_back(x);
            unde[x]=cle;
        }
        comps[cri].clear();
        random_shuffle(comps[cle].begin(),comps[cle].end());
        bool sters=0;
        for(int i=0;i<ord.size();i++)
        {
            if(ord[i]==cri)
            {
                sters=1;
                ord.erase(ord.begin()+i);
                break;
            }
        }
    }
}

Compilation message

icc.cpp: In function 'int wirtz(int)':
icc.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=poz+1;i<ord.size();i++)
      |                     ~^~~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:111:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |         for(int i=0;i<ord.size();i++)
      |                     ~^~~~~~~~~~~
icc.cpp:110:14: warning: variable 'sters' set but not used [-Wunused-but-set-variable]
  110 |         bool sters=0;
      |              ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 604 KB Ok! 104 queries used.
2 Correct 4 ms 628 KB Ok! 105 queries used.
# Verdict Execution time Memory Grader output
1 Correct 23 ms 600 KB Ok! 532 queries used.
2 Correct 34 ms 604 KB Ok! 834 queries used.
3 Correct 33 ms 604 KB Ok! 792 queries used.
# Verdict Execution time Memory Grader output
1 Correct 84 ms 604 KB Ok! 1554 queries used.
2 Correct 116 ms 616 KB Ok! 2149 queries used.
3 Correct 92 ms 628 KB Ok! 1726 queries used.
4 Correct 98 ms 848 KB Ok! 1711 queries used.
# Verdict Execution time Memory Grader output
1 Correct 87 ms 616 KB Ok! 1618 queries used.
2 Correct 92 ms 612 KB Ok! 1685 queries used.
3 Correct 97 ms 628 KB Ok! 1816 queries used.
4 Correct 94 ms 852 KB Ok! 1625 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 604 KB Too many queries! 1946 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 624 KB Too many queries! 1962 out of 1625
2 Halted 0 ms 0 KB -