답안 #1074811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074811 2024-08-25T14:20:25 Z Thanhs CEOI16_icc (CEOI16_icc) C++14
0 / 100
2000 ms 856 KB
#include "icc.h"
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define double long double
 
// #define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define fi first
#define se second
#define all(x) x.begin(), x.end()
 
mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}
 
const int NM = 105;
 
int query(vector<int>& a, vector<int>& b)
{
    int A[a.size()], B[b.size()];
    for (int i = 0; i < a.size(); i++)
        A[i] = a[i];
    for (int i = 0; i < b.size(); i++)
        B[i] = b[i];
    return query((int)a.size(), (int)b.size(), A, B);
}
 
int BS(vector<int> a, vector<int>& b)
{
    vector<int> bs = a;
    int l = 0, r = bs.size();
    while (l < r - 1)
    {
        a.clear();
        int m = l + r >> 1;
        for (int i = 1; i <= m; i++)
            a.push_back(bs[i - 1]);
        if (query(a, b))
            r = m;
        else
            l = m;
    }
    return bs[r - 1];
}
 
int rs[NM], id[NM];
vector<int> v[NM];
set<int> s, did;
vector<int> a, b;
 
void merge(int x, int y)
{
    if (v[x].size() < v[y].size())
        swap(x, y);
    s.erase(x);
    s.erase(y);
    for (int t : v[y])
        v[x].push_back(t);
    s.insert(y);
}
 
 
void run(int N)
{
    for (int i = 1; i <= N; i++)
    {
        v[i].push_back(i);
        s.insert(i);
    }
    for (int n = N; n >= 1; n--)
    {
        iota(rs + 1, rs + 1 + n, 1);
        random_shuffle(rs + 1, rs + 1 + n);
        auto it = s.begin();
        for (int i = 1; i <= n; i++, it = next(it))
            id[i] = *it;
        int mid = -1;
        did.clear();
        while (1)
        {
            mid = rand(1, n - 1);
            if (did.find(mid) != did.end())
                continue;
            did.insert(mid);
            a.clear(); b.clear();
            for (int i = 1; i <= n; i++)
                for (auto t : v[id[rs[i]]])
                {
                    if (i <= mid)
                        a.push_back(t);
                    else
                        b.push_back(t);
                }
            if (query(a, b))
                break;
        }
        int x = BS(a, b), y = BS(b, a);
        setRoad(x, y);
        merge(x, y);
    }
}

Compilation message

icc.cpp: In function 'int query(std::vector<int>&, std::vector<int>&)':
icc.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
icc.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < b.size(); i++)
      |                     ~~^~~~~~~~~~
icc.cpp: In function 'int BS(std::vector<int>, std::vector<int>&)':
icc.cpp:41:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |         int m = l + r >> 1;
      |                 ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2088 ms 448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2036 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2029 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2068 ms 656 KB Time limit exceeded
2 Halted 0 ms 0 KB -