#include<bits/stdc++.h>
#include<communication.h>
using namespace std;
mt19937 rngQ(23478123);
long long K = rngQ();
void encode(int N, int X) {
vector <long long> v(250, -1);
vector < long long > b1, b2;
long long mx = 130;
mt19937 rng(K);
for(long long i = 0; i < 250; i++){
if(rng() % 3 == 1 && (!i || v[i - 1] == -1) ){
mx--;
v[i] = rng()%2;
}else{
if(rng()%2){
b1.push_back(i);
}
else{
b2.push_back(i);
}
}
}
for(auto u : b1) v[u] = (1 << 0) & X;
for(auto u : b2) v[u] = (X >> 1) & 1;
for(auto u : v){
send(u);
}
return;
}
std::pair<int, int> decode(int N) {
vector <long long> v(250, -1);
long long mx = 130;
mt19937 rng2(K);
vector < long long > rem, b1, b2;
for(long long i = 0; i < 250; i++){
if(rng2() % 3 == 1 && (!i || v[i - 1] == -1) ){
mx--;
v[i] = rng2() % 2;
}else{
if(rng2() % 2){
b1.push_back(i);
}
else{
b2.push_back(i);
}
}
}
vector < long long > g(250);
for(long long i = 0; i < 250; i++){
g[i] = receive();
}
long long works = 0;
long long flag1 = 0;
long long flag2 = 0;
long long value2 = 0;
long long value3 = 0;
for(auto u : b1){
if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]){
works |= g[u];
flag1 = 1;
}
if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]){
works |= g[u];
flag1 = 1;
}
value2 += (g[u] == 0 ? -1 : 1);
}
for(auto u : b2){
if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]) works |= (g[u] << 1), flag2 = 1;
if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]) works |= (g[u] << 1), flag2 = 1;
value3 += (g[u] == 0 ? -1 : 1);
}
long long a1 = works, a2 = works;
if(!flag1 && !flag2){
if(max(value2, value3) == value2){
if(value2 >= 0) a1 |= 1, a2 |= 1;
if(value3 >= 0) a2 |= 2;
}else{
if(value3 >= 0) a1 |= 2, a2 |= 2;
if(value2 >= 0) a1 |= 1;
}
}else{
if(!flag1 && value2 >= 0){
a1 |= 1;
}
if(!flag2 && value3 >= 0){
a1 |= 2;
}
}
a1 = min((int)a1, N);
a1 = max(1, (int)a1);
a2 = max(1, (int)a2);
a2 = min((int)a2, N);
while(a1 == a2){
a1++;
if(a1 == N+1){
a1 = 1;
}
}
return {a1, a2};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
257 ms |
1668 KB |
Output is correct |
2 |
Correct |
316 ms |
1740 KB |
Output is correct |
3 |
Correct |
374 ms |
1672 KB |
Output is correct |
4 |
Correct |
263 ms |
1776 KB |
Output is correct |
5 |
Incorrect |
175 ms |
200 KB |
Not correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
942 ms |
296 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |