#include <bits/stdc++.h>
#include "Alice.h"
using namespace std;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
const int N = 5000;
const int B = 1000;
const int CNT = (N - B)/25;
vector<int> bits[25];
#define myrand( l , r , rng) uniform_int_distribution<int>(l , r)(rng)
std::vector<std::pair<int,int>> Alice(){
mt19937 rng1(1313);
mt19937 rng2(chrono::steady_clock::now().time_since_epoch().count());
vector<int> perm;
vector<pair<int ,int>> vp;
for(int i = 1 ; i <= N ; i++)
{
perm.push_back(i);
}
shuffle(perm.begin() , perm.end() , rng1);
vector<int> tree = {perm[0]};
for(int i = 1 ; i < B ; i++)
{
vp.push_back({perm[i] , perm[myrand(0 , (int)tree.size() - 1 , rng2)]});
tree.push_back(perm[i]);
}
assert((int)tree.size() == B);
for(int i = 0 ; i < 25 ; i++)
{
for(int j = B + i * CNT ; j < B + (i + 1) * CNT ; j++)
{
bits[i].push_back(perm[j]);
}
}
long long X = setN(N);
vector<int> all;
for(int i = 0 ; i < 25 ; i++)
{
if((1<<i) & X)
{
for(auto j : bits[i])
{
vp.push_back({tree[myrand(0 , (int)tree.size() - 1 , rng2)] , j});
all.push_back(j);
}
}
}
for(int i =0 ; i < 25 ; i++)
{
if((1<<i) & X)
continue;
for(auto j : bits[i])
{
vp.push_back({all[myrand(0 , (int)all.size() - 1 , rng2)] , j});
}
}
shuffle(vp.begin() , vp.end() , rng2);
assert((int)vp.size() == N - 1);
return vp;
}
#include <bits/stdc++.h>
#include "Bob.h"
using namespace std;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
const int N = 5000;
const int B = 1000;
const int CNT = (N - B)/25;
int label[N + 1];
#define myrand( l , r , rng) uniform_int_distribution<int>(l , r)(rng)
long long Bob(std::vector<std::pair<int,int>> V){
mt19937 rng1(1313);
// add your code here
vector<int> perm;
set<int> s;
for(int i = 1 ; i <= N ; i++)
{
perm.push_back(i);
}
shuffle(perm.begin() , perm.end() , rng1);
for(int i = 0 ; i < B ; i++)
s.insert(perm[i]);
for(int i = 0 ; i < 25 ; i++)
{
for(int j = B + i * CNT ; j < B + (i + 1) * CNT ; j++)
{
label[perm[j]] = i;
}
}
long long X = 0;
for(auto [a , b] : V)
{
if(s.count(a) && !s.count(b))
{
X|=(1ll<<label[b]);
}
}
return X;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1084 KB |
Correct. |
2 |
Correct |
2 ms |
1076 KB |
Correct. |
3 |
Incorrect |
2 ms |
1076 KB |
Incorrect answer. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1084 KB |
Correct. |
2 |
Correct |
2 ms |
1076 KB |
Correct. |
3 |
Incorrect |
2 ms |
1076 KB |
Incorrect answer. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1084 KB |
Correct. |
2 |
Correct |
2 ms |
1076 KB |
Correct. |
3 |
Incorrect |
2 ms |
1076 KB |
Incorrect answer. |
4 |
Halted |
0 ms |
0 KB |
- |