Submission #1057630

# Submission time Handle Problem Language Result Execution time Memory
1057630 2024-08-14T02:02:27 Z thieunguyenhuy ICC (CEOI16_icc) C++17
Compilation error
0 ms 0 KB
#ifndef hwe
	#include "icc.h"
#endif

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

#define popcount(n) (__builtin_popcountll((n)))
#define clz(n) (__builtin_clzll((n)))
#define ctz(n) (__builtin_ctzll((n)))
#define lg(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))

#define Int __int128
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;

template <class T1, class T2>
bool maximize(T1 &x, T2 y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <class T1, class T2>
bool minimize(T1 &x, T2 y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template <class T>
void remove_duplicate(vector<T> &ve) {
    sort (ve.begin(), ve.end());
    ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T> T random(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}
template <class T> T random(T r) {
    return rng() % r;
}

const int N = 100 + 5;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;

#ifdef hwe
int query(int sza, int szb, int a[], int b[]);
void setRoad(int u, int v);
#endif

int a[N], b[N];
vector<int> S[N];

void run(int n) {
	vector<int> components(n); iota(components.begin(), components.end(), 1);

	for (auto &x : components) S[x] = {x};

	int sza = 0, szb = 0;
	for (int _ = 1; _ < n; ++_) {
		for (int b = 0; MASK(b) < components.size(); ++b) {
			vector<int> ones, zeros;
			for (int i = 0; i < components.size(); ++i) {
				if (BIT(i, b)) ones.emplace_back(i);
				else zeros.emplace_back(i);
			}

			sza = 0, szb = 0;
			for (auto &x : zeros) for (auto &y : S[x]) {
				a[sza++] = y;
			}
			for (auto &x : ones) for (auto &y : S[y]) {
				b[szb++] = y;
			}

			int tmp = query(sza, szb, a, b);
			if (tmp == 1) break;
		}

		int low = 1, high = sza, pu = -1, pv = -1;
		while (low <= high) {
			int mid = low + high >> 1;
			if (query(mid, szb, a, b)) high = (pu = mid) - 1;
			else low = mid + 1;
		}
		assert(pu != -1);

		low = 1, high = szb;
		while (low <= high) {
			int mid = low + high >> 1;
			if (query(pu, mid, a, b)) high = (pv = mid) - 1;
			else low = mid + 1;
		}
		assert(pv != -1);

		int u = a[pu - 1], v = b[pv - 1];
		setRoad(u, v);
	}

	assert(false);
}

#ifdef hwe
signed main() {


    cerr << '\n'; return 0;
}
#endif

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:85:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |   for (int b = 0; MASK(b) < components.size(); ++b) {
      |                           ^
icc.cpp:87:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |    for (int i = 0; i < components.size(); ++i) {
      |                    ~~^~~~~~~~~~~~~~~~~~~
icc.cpp:96:42: error: 'y' was not declared in this scope
   96 |    for (auto &x : ones) for (auto &y : S[y]) {
      |                                          ^
icc.cpp:97:6: error: invalid types 'int[int]' for array subscript
   97 |     b[szb++] = y;
      |      ^
icc.cpp:96:15: warning: unused variable 'x' [-Wunused-variable]
   96 |    for (auto &x : ones) for (auto &y : S[y]) {
      |               ^
icc.cpp:100:33: error: invalid conversion from 'int' to 'int*' [-fpermissive]
  100 |    int tmp = query(sza, szb, a, b);
      |                                 ^
      |                                 |
      |                                 int
In file included from icc.cpp:2:
icc.h:10:38: note:   initializing argument 4 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                                 ~~~~~^
icc.cpp:106:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  106 |    int mid = low + high >> 1;
      |              ~~~~^~~~~~
icc.cpp:114:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  114 |    int mid = low + high >> 1;
      |              ~~~~^~~~~~