#include "Ali.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int N;
vector<int> G[10005];
int d[10005];
}
void Init(int _N, std::vector<int> U, std::vector<int> V) {
N = _N;
for (int i = 0; i < N; i++) G[i].clear();
for (int i = 0; i < N-1; i++){
G[U[i]].push_back(V[i]);
G[V[i]].push_back(U[i]);
}
for (int i = 0; i < N; i++){
SetID(i, i);
}
}
void dfs(int u, int p){
for (auto v : G[u]){
if (v == p) continue;
d[v] = d[u]+1;
dfs(v,u);
}
}
int findDist(int U, int V){
d[U] = 0;
dfs(U, -1);
///printf("dist between %d and %d is %d\n",U,V,d[V]);
return d[V];
}
std::string SendA(std::string S) {
int ID = 0;
for (int i = 0; i < 20; i++){
ID *= 2;
ID += (S[i]-'0');
}
string T = "";
ID <<= 6;
for (int j = 0; j < 64; j++){
int TARGET = ID + j;
int CUR = 0;
for (int i = 0; i < N; i++){
if (CUR + i > TARGET){
int X = i, Y = TARGET-CUR;
int D = findDist(X,Y);
for (int k = 12; k >= 0; k--){
T += (char)((D>>k&1)+'0');
}
break;
}
CUR += i;
}
}
///cout << "Ali sending " << T << endl;
return T;
}
#include "Benjamin.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int ID = 0;
}
std::string SendB(int N, int X, int Y) {
ID = 0;
if (X < Y) swap(X,Y);
for (int i = 0; i < X; i++){
ID += i;
}
ID += Y;
string s = "";
for (int i = 25; i > 5; i--){
s += (char)((ID>>i&1)+'0');
}
///cout << "Ben sending " << s << " " << ID << endl;
return s;
}
int Answer(std::string T) {
int offset = ID&(0b111111);
int ans = 0;
for (int i = offset*13; i < offset*13+13; i++){
ans *= 2;
ans += (T[i]-'0');
}
return ans;
}
Compilation message
grader_ali.cpp:10:8: warning: '{anonymous}::_randmem' defined but not used [-Wunused-variable]
10 | char _randmem[12379];
| ^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
656 KB |
Output is correct |
2 |
Correct |
2 ms |
656 KB |
Output is correct |
3 |
Correct |
1 ms |
656 KB |
Output is correct |
4 |
Correct |
2 ms |
656 KB |
Output is correct |
5 |
Correct |
1 ms |
656 KB |
Output is correct |
6 |
Correct |
19 ms |
1320 KB |
Output is correct |
7 |
Correct |
22 ms |
1168 KB |
Output is correct |
8 |
Correct |
24 ms |
1240 KB |
Output is correct |
9 |
Correct |
24 ms |
1168 KB |
Output is correct |
10 |
Correct |
26 ms |
1316 KB |
Output is correct |
11 |
Correct |
12 ms |
1208 KB |
Output is correct |
12 |
Correct |
12 ms |
1320 KB |
Output is correct |
13 |
Correct |
13 ms |
1264 KB |
Output is correct |
14 |
Correct |
11 ms |
1280 KB |
Output is correct |
15 |
Incorrect |
13 ms |
1300 KB |
Incorrect |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
656 KB |
Output is partially correct |
2 |
Incorrect |
160 ms |
1372 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |