# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1233559 | Tenis0206 | How to Avoid Disqualification in 75 Easy Steps (CEOI23_avoid) | C++20 | 1 ms | 428 KiB |
#include <bits/stdc++.h>
#include "avoid.h"
using namespace std;
pair<int,int> scout(int r, int h)
{
if(h == 1 && r == 10)
{
for(int b=0; b<10; b++)
{
vector<int> p;
for(int i=1; i<=1000; i++)
{
if((i & (1<<b)) == 0)
{
p.push_back(i);
}
}
send(p);
}
vector<int> r = wait();
int rez = 0;
for(int b=0; b<10; b++)
{
if(!r[b])
{
rez += (1<<b);
}
}
return {rez, rez};
}
if(r == 20 && h == 20)
{
int poz1 = 0, poz2 = 0;
int st = 1;
int dr = 1000;
while(st <= dr)
{
int mij = (st + dr) >> 1;
vector<int> p;
for(int i=1; i<=mij; i++)
{
p.push_back(i);
}
send(p);
vector<int> r = wait();
if(r.front() == 1)
{
poz1 = mij;
dr = mij - 1;
}
else
{
st = mij + 1;
}
}
st = poz1 + 1;
dr = 1000;
while(st <= dr)
{
int mij = (st + dr) >> 1;
vector<int> p;
for(int i=poz1+1; i<=mij; i++)
{
p.push_back(i);
}
send(p);
vector<int> r = wait();
if(r.front() == 1)
{
poz2 = mij;
dr = mij - 1;
}
else
{
st = mij + 1;
}
}
if(poz2 == 0)
{
poz2 = poz1;
}
return {poz1, poz2};
}
if(h == 2 && r == 30)
{
for(int b=0; b<10; b++)
{
vector<int> p;
for(int i=1; i<=1000; i++)
{
if((i & (1<<b)) == 0)
{
p.push_back(i);
}
}
send(p);
}
for(int b=0; b<10; b++)
{
vector<int> p;
for(int i=1; i<=1000; i++)
{
if((i & (1<<b)) != 0)
{
p.push_back(i);
}
}
send(p);
}
vector<int> r = wait();
int split = -1;
for(int b=0; b<10; b++)
{
if(r[b] && r[b + 10])
{
split = b;
}
}
if(split == -1)
{
for(int b=0; b<10; b++)
{
vector<int> p;
for(int i=1; i<=1000; i++)
{
if((i & (1<<b)) == 0)
{
p.push_back(i);
}
}
send(p);
}
vector<int> r = wait();
int rez = 0;
for(int b=0; b<10; b++)
{
if(!r[b])
{
rez += (1<<b);
}
}
return {rez, rez};
}
for(int b=0; b<10; b++)
{
if(!r[b] || !r[b + 10])
{
continue;
}
vector<int> p;
for(int i=1; i<=1000; i++)
{
if((i & (1<<b)) == 0 && (i & (1<<split)) == 0)
{
p.push_back(i);
}
}
send(p);
}
for(int b=0; b<10; b++)
{
if(!r[b] || !r[b + 10])
{
continue;
}
vector<int> p;
for(int i=1; i<=1000; i++)
{
if((i & (1<<b)) == 0 && (i & (1<<split)) != 0)
{
p.push_back(i);
}
}
send(p);
}
vector<int> r1 = wait();
int rez1 = 0, rez2 = 0;
int poz = 0;
for(int b=0; b<10; b++)
{
if(!r[b])
{
rez1 += (1<<b);
continue;
}
if(!r[b + 10])
{
continue;
}
if(!r1[poz])
{
rez1 += (1<<b);
}
++poz;
}
for(int b=0; b<10; b++)
{
if(!r[b])
{
rez2 += (1<<b);
continue;
}
if(!r[b + 10])
{
continue;
}
if(!r1[poz])
{
rez2 += (1<<b);
}
++poz;
}
if(rez2 < rez1)
{
swap(rez1, rez2);
}
return {rez1, rez2};
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |