#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma,popcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename T, typename cmp = less<T>>
using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
constexpr int N = 105;
int color[N];
vi adj[N];
void dfs(int u) {
for(int v: adj[u]) if(!~color[v]) {
color[v] = color[u];
dfs(v);
}
}
#include "icc.h"
int query(vi& a, vi& b) {
return query(a.size(), b.size(), a.data(), b.data());
}
void run(int N) {
int& n = N;
rep(_, n - 1) {
int w = 0;
vi l, r;
do {
memset(color, -1, sizeof(color));
rep1(i, n) if(!~color[i]) {
color[i] = rng() & 1;
dfs(i);
}
l.clear(), r.clear();
rep1(i, n) (color[i] ? l : r).pb(i);
w = query(l, r);
} while(!w);
while(l.size() > 1) {
vi a, b;
rep(i, l.size()) (i & 1 ? a : b).pb(l[i]);
if(query(a, r)) l = a;
else l = b;
}
while(r.size() > 1) {
vi a, b;
rep(i, r.size()) (i & 1 ? a : b).pb(r[i]);
if(query(l, a)) r = a;
else r = b;
}
int u = l[0], v = r[0];
adj[u].pb(v);
adj[v].pb(u);
setRoad(u, v);
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:23:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | #define rep(i, n) for (int i=0; i<(n); i++)
| ^
icc.cpp:79:13: note: in expansion of macro 'rep'
79 | rep(i, l.size()) (i & 1 ? a : b).pb(l[i]);
| ^~~
icc.cpp:23:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | #define rep(i, n) for (int i=0; i<(n); i++)
| ^
icc.cpp:85:13: note: in expansion of macro 'rep'
85 | rep(i, r.size()) (i & 1 ? a : b).pb(r[i]);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Ok! 99 queries used. |
2 |
Correct |
8 ms |
436 KB |
Ok! 110 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
488 KB |
Ok! 557 queries used. |
2 |
Correct |
51 ms |
468 KB |
Ok! 855 queries used. |
3 |
Correct |
53 ms |
488 KB |
Ok! 832 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
488 KB |
Ok! 1533 queries used. |
2 |
Correct |
164 ms |
492 KB |
Ok! 2180 queries used. |
3 |
Correct |
133 ms |
484 KB |
Ok! 1689 queries used. |
4 |
Correct |
123 ms |
484 KB |
Ok! 1757 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
496 KB |
Ok! 1697 queries used. |
2 |
Correct |
133 ms |
504 KB |
Ok! 1699 queries used. |
3 |
Correct |
143 ms |
484 KB |
Ok! 1871 queries used. |
4 |
Correct |
115 ms |
488 KB |
Ok! 1589 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
492 KB |
Too many queries! 2027 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
142 ms |
468 KB |
Too many queries! 1948 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |