답안 #706965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706965 2023-03-08T08:01:59 Z socpite CEOI16_icc (CEOI16_icc) C++14
90 / 100
123 ms 616 KB
#include"icc.h"
#include<bits/stdc++.h>
using namespace std;

#define f first
#define s second

typedef long long ll;
typedef long double ld;

const int maxn = 105;
const int mod = 998244353;
 
int t, n;

map<int, int> mp;

/*int query(int sza, int szb, int a[], int b[]){
    cout << sza << endl;
    for(int i = 0; i < sza; i++)cout << a[i] << " ";
    cout << endl;
    cout << szb << endl;
    for(int i = 0; i < szb; i++)cout << b[i] << " ";
    cout << endl;
    int x;
    cin >> x;
    return x;
}

void setRoad(int a, int b){
    cout << "FOUND " << a << " " << b << endl;
}*/

int up[maxn];

int Find(int x){
    if(!up[x])return x;
    else return up[x] = Find(up[x]);
}

void Union(int a, int b){
    a = Find(a);
    b = Find(b);
    up[a] = b;
}

int arr1[maxn], arr2[maxn];

int gt(vector<int> a, vector<int> b){
    //cout << a.size() << " " << b.size() << "\n";
    if(a.empty() || b.empty())return 0;
    for(int i = 0; i < a.size(); i++)arr1[i] = a[i];
    for(int i = 0; i < b.size(); i++)arr2[i] = b[i];
    return query(a.size(), b.size(), arr1, arr2);
}

int bs(vector<int> a, vector<int> b){
    int l = 0, r = a.size()-1;
    while(l < r){
        int mid = (l+r+1)>>1;
        if(gt(vector<int>(a.begin(), a.begin()+mid), b))r = mid-1;
        else l = mid;
    }
    return a[l];
}

void findedge(vector<int> a, vector<int> b){
    assert(!a.empty() && !b.empty());
    int h1 = bs(a, b), h2 = bs(b, a);
    Union(h1, h2);
    setRoad(h1, h2);
}

void run(int N){
    n = N;
    for(int i = 0; i < n-1; i++){
        mp.clear();
        int crr = 0;
        for(int i = 1; i <= n; i++)if(mp.find(Find(i)) == mp.end())mp[Find(i)] = crr++;
        for(int j = 0; j < 10; j++){
            //cout << i << " " << j << endl;
            vector<int> v[2];
            for(int k = 1; k <= n; k++)v[(mp[Find(k)]>>j)&1].push_back(k);
            //cout << v[0].size() << " " << v[1].size() << endl;
            if(gt(v[0], v[1])){
                findedge(v[0], v[1]);
                break;
            }
        }
    }
}

Compilation message

icc.cpp: In function 'int gt(std::vector<int>, std::vector<int>)':
icc.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i = 0; i < a.size(); i++)arr1[i] = a[i];
      |                    ~~^~~~~~~~~~
icc.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i = 0; i < b.size(); i++)arr2[i] = b[i];
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 468 KB Ok! 96 queries used.
2 Correct 5 ms 468 KB Ok! 102 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 500 KB Ok! 555 queries used.
2 Correct 37 ms 480 KB Ok! 672 queries used.
3 Correct 36 ms 468 KB Ok! 661 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 496 KB Ok! 1463 queries used.
2 Correct 120 ms 504 KB Ok! 1638 queries used.
3 Correct 107 ms 504 KB Ok! 1578 queries used.
4 Correct 108 ms 592 KB Ok! 1544 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 508 KB Ok! 1574 queries used.
2 Correct 119 ms 504 KB Ok! 1526 queries used.
3 Correct 111 ms 500 KB Ok! 1623 queries used.
4 Correct 110 ms 496 KB Ok! 1517 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 488 KB Ok! 1609 queries used.
2 Correct 123 ms 496 KB Ok! 1607 queries used.
3 Correct 115 ms 468 KB Ok! 1646 queries used.
4 Correct 111 ms 500 KB Ok! 1607 queries used.
5 Correct 101 ms 468 KB Ok! 1505 queries used.
6 Correct 122 ms 504 KB Ok! 1542 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 616 KB Ok! 1606 queries used.
2 Incorrect 123 ms 496 KB Too many queries! 1639 out of 1625
3 Halted 0 ms 0 KB -