답안 #604613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604613 2022-07-25T08:09:30 Z nghiass001 CEOI16_icc (CEOI16_icc) C++17
0 / 100
3 ms 504 KB
#include "icc.h"
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, l, r) for(int i = (l); i < (r); ++i)
#define FORD(i, r, l) for(int i = (r); i >= (l); --i)
using namespace std;
const int N = 1e2 + 5;
int n, dad[N], color[N];
vector<vector<int>> Q;
vector<int> list_a, list_b;

int query() {
  	int tmp = query(list_a.size(), list_b.size(), list_a.data(), list_b.data()); 
  	list_a.clear();
    list_b.clear();
    return tmp;
}
int div2() {
    int tmp = 1;
    while (true) {
        Q.clear();
        Q.resize(tmp);
        FOR(i, 1, n) if (dad[i] == i) Q[color[dad[i]]].push_back(i);
        REP(i, 0, tmp) {
            int mid = Q[i].size() / 2;
            random_shuffle(Q[i].begin(), Q[i].end());
            REP(j, 0, mid) color[Q[i][j]] = i * 2;
            REP(j, mid, Q[i].size()) color[Q[i][j]] = i * 2 + 1;
        }
        tmp *= 2;
        Q.clear();
        Q.resize(tmp);
        FOR(i, 1, n) Q[color[dad[i]]].push_back(i);

        int sza = 0, szb = 0;
        FOR(i, 1, n) {
            if (color[dad[i]] % 2 == 0) list_a.push_back(i);
            else list_b.push_back(i);
        }
        if (query()) break;
    }
    return tmp;
}

int ask(int lft, int rgt) {
    FOR(id, lft, rgt) {
        for(int i : Q[id]) {
            if (id % 2 == 0) list_a.push_back(i);
            else list_b.push_back(i);
        }
    }
    return query();
}

int ask2(int id, int lx, int rx, int ly, int ry) {
    FOR(i, lx, rx) list_a.push_back(Q[id * 2][i]);
    FOR(i, ly, ry) list_b.push_back(Q[id * 2 + 1][i]);
    return query();
}

void run(int nn) {
    srand(time(NULL));
    n = nn;
    FOR(i, 1, n) dad[i] = i;
    REP(step, 1, n) {
        fill(color + 1, color + n + 1, 0);
        int lft = 0, rgt = div2() / 2 - 1, mid;
        while (lft < rgt) {
            mid = (lft + rgt) / 2;
            if (ask(lft, mid) == 1) rgt = mid;
            else lft = mid + 1;
        }

        int lx = 0, rx = Q[lft * 2].size() - 1;
        int ly = 0, ry = Q[lft * 2 + 1].size() - 1;

        while (lx < rx) {
            mid = (lx + rx) / 2;
            if (ask2(lft, lx, mid, ly, ry) == 1) rx = mid;
            else lx = mid + 1;
        }

        while (ly < ry) {
            mid = (ly + ry) / 2;
            if (ask2(lft, lx, rx, ly, mid) == 1) ry = mid;
            else ly = mid + 1;
        }

        setRoad(Q[lft * 2][lx], Q[lft * 2 + 1][ly]);
        FOR(i, 1, n) if (dad[i] == Q[lft * 2 + 1][ly]) dad[i] = dad[Q[lft * 2][lx]];
    }
}

Compilation message

icc.cpp: In function 'int div2()':
icc.cpp:4:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define REP(i, l, r) for(int i = (l); i < (r); ++i)
      |                                         ^
icc.cpp:28:13: note: in expansion of macro 'REP'
   28 |             REP(j, mid, Q[i].size()) color[Q[i][j]] = i * 2 + 1;
      |             ^~~
icc.cpp:35:13: warning: unused variable 'sza' [-Wunused-variable]
   35 |         int sza = 0, szb = 0;
      |             ^~~
icc.cpp:35:22: warning: unused variable 'szb' [-Wunused-variable]
   35 |         int sza = 0, szb = 0;
      |                      ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Wrong road!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -