Submission #919577

# Submission time Handle Problem Language Result Execution time Memory
919577 2024-02-01T07:29:27 Z nasir_bashirov ICC (CEOI16_icc) C++11
0 / 100
1 ms 344 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
#include "icc.h"
using namespace std;

#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
    ios_base::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)\

// #define int long long

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

struct DSU{
    vi par;
    int components;
    DSU(int sz){
        components = sz;
        par.resize(sz + 5, -1);
    }
    int Find(int u){
        if(par[u] < 0)   return u;
        else    return par[u] = Find(par[u]);
    }
    bool Union(int u, int v){
        u = Find(u), v = Find(v);
        if(u != v){
            if(par[u] < par[v]){
                swap(u, v);
            }
            par[u] += par[v];
            par[v] = u;
            components--;
            return true;
        }
        else{
            return false;
        }
    }
};

int n;

void run(int N){
    n = N;
    DSU g(n);
    for(int t = 1; t < n; t++){
        bool f = false;
        pii pr = {0, 0};
        for(int i = 1; i <= n and !pr.second; i++){
            vi vv;
            for(int j = 1; j <= n; j++){
                if(g.Find(j) != g.Find(i)) continue;
                vv.push_back(j);
            }
            int a[] = {i}, b[vv.size()];
            for(int j = 0; j < vv.size(); j++){
                b[j] = vv[j];
            }
            if(query(1, vv.size(), a, b)){
                if(pr.first)    pr.second = i;
                else    pr.first = i;
                break;
            }
        }
        g.Union(pr.first, pr.second);
        setRoad(pr.first, pr.second);
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:70:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             for(int j = 0; j < vv.size(); j++){
      |                            ~~^~~~~~~~~~~
icc.cpp:61:14: warning: unused variable 'f' [-Wunused-variable]
   61 |         bool f = false;
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -