Submission #57870

# Submission time Handle Problem Language Result Execution time Memory
57870 2018-07-16T13:01:20 Z MatheusLealV ICC (CEOI16_icc) C++17
18 / 100
534 ms 876 KB
#include "icc.h"
#define N 105
#include <bits/stdc++.h>
using namespace std;
 
set<int> grafo[N];
 
int pai[N], peso[N];
 
int Find(int x)
{
    if(x == pai[x]) return x;
 
    return pai[x] = Find(pai[x]);
}
 
void join(int a, int b)
{
    a = Find(a), b = Find(b);
 
    if(a == b) return;
 
    if(peso[a] > peso[b]) pai[b] = a;
 
    else if(peso[a] < peso[b]) pai[a] = b;
 
    else pai[a] = b, peso[b] ++; 
}
 
void run(int n)
{
    for(int i = 1; i <= n; i++)
    {
        pai[i] = i;
    }
 
    for(int i = 1; i < n; i++)
    {
        vector<int> ok;

        vector<int> valores;

        for(int a = 1; a <= n; a++) valores.push_back(a);

        random_shuffle(valores.begin(), valores.end());
 
        for(auto a: valores)
        {
            int esq[N], dir[N], id = 0;

            if(ok.size() >= 2 or (ok.size() == 1 and Find(a) == Find(ok[0]))) continue;
 
            esq[0] = a;
 
            for(int b = 1; b <= n; b++)
            {
                if(Find(a) != Find(b))
                {
                    dir[id] = b;
 
                    id ++;
                }
            }
 
            if(query(1, id, esq, dir) > 0)
            {
                ok.push_back(a);
            }
        }
 
        join(ok[0], ok[1]);
 
 
        //cout<<i<<" "<<ok.size()<<" "<<" ROAD "<<ok[0]<<" "<<ok[1]<<"\n";
        setRoad(ok[0], ok[1]);
    }
}
 
# Verdict Execution time Memory Grader output
1 Correct 18 ms 508 KB Ok! 210 queries used.
2 Correct 17 ms 508 KB Ok! 203 queries used.
# Verdict Execution time Memory Grader output
1 Correct 210 ms 764 KB Ok! 2431 queries used.
2 Correct 202 ms 764 KB Ok! 2436 queries used.
3 Correct 205 ms 764 KB Ok! 2442 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 534 ms 764 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 489 ms 796 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 394 ms 796 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 356 ms 876 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -