# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
104283 |
2019-04-04T17:44:42 Z |
tmk |
ICC (CEOI16_icc) |
C++17 |
|
366 ms |
760 KB |
#include<bits/stdc++.h>
#include "icc.h"
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
return os << "(" << P.st << "," << P.nd << ")";
}
constexpr int maxn = 105;
using Component = vector<int>;
int n;
vector<Component> C;
vector<int> get_vertices(vector<int>& ind) {
vector<int> ret;
for(auto i:ind)
for(auto x:C[i])
ret.push_back(x);
return ret;
}
int make_query(vector<int> l, vector<int> r) {
return query(l.size(), r.size(), l.data(), r.data());
}
void merge(int a, int b) {
auto f = [&](int x) {
for(size_t i=0; i<C.size(); i++)
if(find(all(C[i]), x) != C[i].end())
return i;
return C.size();
};
a = f(a), b = f(b);
for(auto x:C[b])
C[a].push_back(x);
C[b] = C.back();
C.pop_back();
}
void run(int _n) {
n = _n;
for(int i=1; i<=n; i++) {
C.push_back({i});
}
// mt19937 rng(time(0));
for(int _=0; _<n-1; _++) {
vector<int> L, R, ind(C.size());
iota(all(ind), 0);
int half = ind.size() / 2;
while(true) {
shuffle(all(ind), mt19937(time(0)));
L.assign(ind.begin(), ind.begin() + half);
R.assign(ind.begin() + half, ind.end());
if(make_query(get_vertices(L), get_vertices(R))) break;
}
L = get_vertices(L);
R = get_vertices(R);
auto it = L.begin(), it2 = L.end();
while(it + 1 != it2) {
auto s = it + distance(it, it2) / 2;
if(make_query(vector<int>(it, s), R))
it2 = s;
else
it = s;
}
int a = *it;
it = R.begin(), it2 = R.end();
while(it + 1 != it2) {
auto s = it + distance(it, it2) / 2;
if(make_query(vector<int>(it, s), L))
it2 = s;
else
it = s;
}
int b = *it;
setRoad(a, b);
merge(a, b);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
640 KB |
Ok! 105 queries used. |
2 |
Incorrect |
176 ms |
560 KB |
Number of queries more than 3000 out of 1500 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
327 ms |
760 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
366 ms |
512 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
319 ms |
572 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
334 ms |
512 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
291 ms |
512 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |