# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
882371 |
2023-12-03T05:38:23 Z |
ono_de206 |
ICC (CEOI16_icc) |
C++14 |
|
89 ms |
1108 KB |
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
//#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int mxn = 110;
int A[mxn], B[mxn], n, par[mxn];
vector<int> g[mxn], all;
int get(int x) {
if(par[x] == x) return x;
return par[x] = get(par[x]);
}
void merge(int x, int y) {
x = get(x);
y = get(y);
if(g[x].size() < g[y].size()) swap(x, y);
all.erase(find(all(all), y));
g[x].insert(g[x].end(), all(g[y]));
par[y] = x;
g[y].clear();
}
int ask(vector<int> a, vector<int> b) {
int sza = 0, szb = 0;
for(int x : a) {
for(int y : g[x]) {
A[sza++] = y;
}
}
for(int x : b) {
for(int y : g[x]) {
B[szb++] = y;
}
}
return query(sza, szb, A, B);
}
pair<int, int> find(vector<int> x, vector<int> y) {
pair<int, int> ret{0, 0};
int A[n + 1], B[n + 1];
int sza, szb = 0;
int l = -1, r = (int)x.size() - 1;
for(int p : y) {
B[szb++] = p;
}
while(r - l > 1) {
int m = (l + r) / 2;
sza = 0;
for(int i = 0; i <= m; i++) {
A[sza++] = x[i];
}
if(query(sza, szb, A, B)) r = m;
else l = m;
}
ret.ff = x[r];
sza = 0;
l = -1, r = (int)y.size() - 1;
for(int p : x) {
A[sza++] = p;
}
while(r - l > 1) {
int m = (l + r) / 2;
szb = 0;
for(int i = 0; i <= m; i++) {
B[szb++] = y[i];
}
if(query(sza, szb, A, B)) r = m;
else l = m;
}
ret.ss = y[r];
return ret;
}
void run(int _n) {
n = _n;
for(int i = 1; i <= n; i++) {
g[i].pb(i);
all.pb(i);
par[i] = i;
}
for(int t = 1; t < n; t++) {
int sz = (int)all.size();
while(sz & (sz - 1)) {
sz++;
all.pb(-1);
}
for(int j = 2; j <= sz; j *= 2) {
int lol = sz / j;
vector<int> a, b;
for(int k = 1; k <= j; k++) {
for(int p = lol * (k - 1); p < lol * k; p++) {
if(all[p] != -1) {
if(k % 2) a.pb(all[p]);
else b.pb(all[p]);
}
}
}
if(ask(a, b)) {
vector<int> aa, bb;
for(int x : a) {
aa.insert(aa.end(), all(g[x]));
}
for(int x : b) {
bb.insert(bb.end(), all(g[x]));
}
pair<int, int> ans = find(aa, bb);
setRoad(ans.ff, ans.ss);
merge(ans.ff, ans.ss);
break;
}
}
while(all.size() && all.back() == -1) {
all.pop_back();
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
604 KB |
Ok! 105 queries used. |
2 |
Correct |
4 ms |
604 KB |
Ok! 103 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
640 KB |
Ok! 579 queries used. |
2 |
Correct |
27 ms |
604 KB |
Ok! 689 queries used. |
3 |
Correct |
28 ms |
628 KB |
Ok! 683 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
600 KB |
Ok! 1376 queries used. |
2 |
Correct |
83 ms |
600 KB |
Ok! 1695 queries used. |
3 |
Correct |
81 ms |
1108 KB |
Ok! 1605 queries used. |
4 |
Correct |
78 ms |
620 KB |
Ok! 1588 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
616 KB |
Ok! 1523 queries used. |
2 |
Correct |
77 ms |
604 KB |
Ok! 1556 queries used. |
3 |
Correct |
80 ms |
600 KB |
Ok! 1626 queries used. |
4 |
Correct |
72 ms |
624 KB |
Ok! 1435 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
896 KB |
Ok! 1635 queries used. |
2 |
Correct |
80 ms |
640 KB |
Ok! 1642 queries used. |
3 |
Correct |
89 ms |
636 KB |
Ok! 1667 queries used. |
4 |
Correct |
83 ms |
640 KB |
Ok! 1628 queries used. |
5 |
Correct |
73 ms |
604 KB |
Ok! 1428 queries used. |
6 |
Correct |
82 ms |
632 KB |
Ok! 1614 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
82 ms |
600 KB |
Too many queries! 1657 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |