Submission #137688

# Submission time Handle Problem Language Result Execution time Memory
137688 2019-07-28T08:34:18 Z darkkcyan ICC (CEOI16_icc) C++14
7 / 100
486 ms 636 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
using namespace std::placeholders;

#define llong long long 
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define all(x) x.begin(), x.end()
// #define rand __rand
// mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
// template<class T = int> T rand(T range = numeric_limits<T>::max()) {
    // return (T)(rng() % range);
// }

int query(vector<int> a, vector<int> b) {
    return query(len(a), len(b), &a[0], &b[0]);
}

class Dsu {
private:
    int n;
    vector<int> set_head;
public:
    Dsu(int n_) : n(n_), set_head(n) {
        for (int i = n; i--; ) {
            set_head[i] = i;
        }
    }

    int find_set(int u) { return u == set_head[u] ? u : set_head[u] = find_set(set_head[u]); }
    bool same_set(int u, int v) {
        return find_set(u) == find_set(v);
    }

    void join(int u, int v) {
        if (rand() & 1) swap(u, v);
        set_head[find_set(u)] = find_set(v);
    }
};

struct solution_batch_1 {
    Dsu dsu;
    solution_batch_1(int n): dsu(n) {
        rep(edge_id, n - 1) {
            bool has_ans = false;
            rep(i, n) {
                for (int f = i + 1; f < n and !has_ans; ++f) {
                    if (dsu.same_set(i, f)) continue;
                    if (!query({i + 1}, {f + 1})) continue;
                    has_ans = 1;
                    setRoad(i + 1, f + 1);
                    dsu.join(i, f);
                }
                if (has_ans) break;
            }
        }
    }
};

void run(int n) {
    solution_batch_1 temp(n);
}
# Verdict Execution time Memory Grader output
1 Correct 66 ms 504 KB Ok! 1015 queries used.
2 Correct 66 ms 632 KB Ok! 1005 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 369 ms 636 KB Number of queries more than 5000 out of 2500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 486 ms 564 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 440 ms 556 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 401 ms 556 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 373 ms 564 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -