# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
707194 |
2023-03-08T15:10:32 Z |
Tuanlinh123 |
ICC (CEOI16_icc) |
C++17 |
|
131 ms |
512 KB |
#include<bits/stdc++.h>
#include "icc.h"
#define ll int
#define ld long double
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
ll a[105], pa[105], Rank[105];
ll Find(ll i)
{
if (pa[i]!=i)
pa[i]=Find(pa[i]);
return pa[i];
}
void Union(ll a, ll b)
{
ll Pa=Find(a), Pb=Find(b);
if (Pa==Pb) return;
if (Rank[Pa]<Rank[Pb]) swap(Pa, Pb);
if (Rank[Pa]==Rank[Pb]) Rank[Pa]++;
pa[Pb]=Pa;
}
ll ask(vector <ll> a, vector <ll> b)
{
ll n=a.size(), m=b.size();
ll A[n], B[m];
for (ll i=0; i<a.size(); i++)
A[i]=a[i];
for (ll i=0; i<b.size(); i++)
B[i]=b[i];
return query(n, m, A, B);
}
ll random(ll l, ll r)
{
return l+rand()%(r-l+1);
}
void run(ll n)
{
srand(070405);
for (ll i=1; i<=n; i++)
pa[i]=i, a[i-1]=i;
for (ll i=1; i<=n*n; i++)
{
ll l=random(0, n-1), r=random(0, n-1);
swap(a[l], a[r]);
}
ll lg=32-__builtin_clz(n);
ll order[lg];
for (ll i=0; i<lg; i++)
order[i]=i;
for (ll k=1; k<n; k++)
{
for (ll i=0; i<lg*lg; i++)
{
ll l=random(0, lg-1), r=random(0, lg-1);
swap(order[l], order[r]);
}
for (ll z=0; z<lg; z++)
{
ll i=order[z];
vector <ll> A, B;
for (ll j=0; j<n; j++)
{
ll Pj=Find(a[j]);
if (Pj&1<<i)
A.pb(a[j]);
else B.pb(a[j]);
}
if (!ask(A, B))
continue;
ll loA=0, hiA=A.size()-1;
while (hiA>loA)
{
ll midA=(hiA+loA)/2;
vector <ll> Anew(A.begin()+loA, A.begin()+midA+1);
if (ask(Anew, B))
hiA=midA;
else loA=midA+1;
}
ll loB=0, hiB=B.size()-1;
while (hiB>loB)
{
ll midB=(hiB+loB)/2;
vector <ll> Bnew(B.begin()+loB, B.begin()+midB+1);
if (ask(A, Bnew))
hiB=midB;
else loB=midB+1;
}
setRoad(A[loA], B[loB]);
Union(A[loA], B[loB]);
break;
}
}
}
Compilation message
icc.cpp: In function 'int ask(std::vector<int>, std::vector<int>)':
icc.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (ll i=0; i<a.size(); i++)
| ~^~~~~~~~~
icc.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (ll i=0; i<b.size(); i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Ok! 101 queries used. |
2 |
Correct |
5 ms |
468 KB |
Ok! 97 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
492 KB |
Ok! 538 queries used. |
2 |
Correct |
42 ms |
468 KB |
Ok! 707 queries used. |
3 |
Correct |
34 ms |
468 KB |
Ok! 681 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
496 KB |
Ok! 1368 queries used. |
2 |
Correct |
124 ms |
488 KB |
Ok! 1755 queries used. |
3 |
Correct |
104 ms |
468 KB |
Ok! 1454 queries used. |
4 |
Correct |
106 ms |
496 KB |
Ok! 1518 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
480 KB |
Ok! 1480 queries used. |
2 |
Correct |
99 ms |
488 KB |
Ok! 1483 queries used. |
3 |
Correct |
131 ms |
484 KB |
Ok! 1659 queries used. |
4 |
Correct |
100 ms |
484 KB |
Ok! 1430 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
484 KB |
Ok! 1620 queries used. |
2 |
Correct |
124 ms |
480 KB |
Ok! 1655 queries used. |
3 |
Correct |
119 ms |
488 KB |
Ok! 1700 queries used. |
4 |
Correct |
114 ms |
468 KB |
Ok! 1591 queries used. |
5 |
Correct |
98 ms |
488 KB |
Ok! 1437 queries used. |
6 |
Correct |
116 ms |
488 KB |
Ok! 1586 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
121 ms |
512 KB |
Too many queries! 1637 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |