#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250005;
vector<int> generate_seq(){
double rat = 1.05;
vector<int> v = {1};
while(v.size() < 256){
int curV = (int)round(rat);
if(curV != v.back()) v.push_back(curV);
rat *= 1.05;
}
return v;
}
vector<int> seq;
vector<int> gph[MAXN];
int dfn[MAXN], sz[MAXN], piv;
void dfs(int x, int p){
sz[x] = 1;
dfn[x] = ++piv;
for(auto &i : gph[x]){
if(i != p){
dfs(i, x);
sz[x] += sz[i];
}
}
while(!binary_search(seq.begin(), seq.end(), sz[x])){
sz[x]++;
piv++;
}
}
void Encode(int N, int A[], int B[]){
for(int i=0; i<N-1; i++){
gph[A[i]].push_back(B[i]);
gph[B[i]].push_back(A[i]);
}
seq = generate_seq();
dfs(0, -1);
for (int i = 0; i < N; ++i) {
sz[i] = lower_bound(seq.begin(), seq.end(), sz[i]) - seq.begin();
Code(i, ((long long)dfn[i] << 8) + sz[i]);
}
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
#define generate_seq fuck
#define seq fuckk
vector<int> generate_seq(){
double rat = 1.05;
vector<int> v = {1};
while(v.size() < 256){
int curV = (int)round(rat);
if(curV != v.back()) v.push_back(curV);
rat *= 1.05;
}
return v;
}
vector<int> seq;
void InitDevice(){
seq = generate_seq();
}
int Answer(long long S, long long T){
int dfnS = (S >> 8);
int szS = S & ((1<<8) - 1);
szS = seq[szS];
int dfnT = (T >> 8);
int szT = T & ((1<<8) - 1);
szT = seq[szT];
if(dfnS <= dfnT && dfnT + szT <= dfnS + szS){
return 1;
}
if(dfnT <= dfnS && dfnS + szS <= dfnT + szT){
return 0;
}
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
12544 KB |
Output is correct |
2 |
Correct |
8 ms |
12392 KB |
Output is correct |
3 |
Correct |
7 ms |
12544 KB |
Output is correct |
4 |
Correct |
8 ms |
12288 KB |
Output is correct |
5 |
Correct |
8 ms |
12288 KB |
Output is correct |
6 |
Correct |
9 ms |
12544 KB |
Output is correct |
7 |
Correct |
9 ms |
12544 KB |
Output is correct |
8 |
Correct |
8 ms |
12544 KB |
Output is correct |
9 |
Correct |
9 ms |
12544 KB |
Output is correct |
10 |
Correct |
9 ms |
12544 KB |
Output is correct |
11 |
Correct |
8 ms |
12288 KB |
Output is correct |
12 |
Correct |
9 ms |
12544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
169 ms |
19568 KB |
Output is correct - L = 191232 |
2 |
Correct |
167 ms |
19440 KB |
Output is correct - L = 192256 |
3 |
Correct |
168 ms |
19440 KB |
Output is correct - L = 189440 |
4 |
Correct |
168 ms |
19424 KB |
Output is correct - L = 201472 |
5 |
Correct |
501 ms |
55280 KB |
Output is correct - L = 77976320 |
6 |
Correct |
494 ms |
55344 KB |
Output is correct - L = 77240064 |
7 |
Correct |
523 ms |
55232 KB |
Output is correct - L = 79631872 |
8 |
Correct |
509 ms |
54776 KB |
Output is correct - L = 95452928 |
9 |
Correct |
419 ms |
56648 KB |
Output is correct - L = 129651456 |
10 |
Correct |
413 ms |
56896 KB |
Output is correct - L = 128323328 |
11 |
Correct |
420 ms |
56552 KB |
Output is correct - L = 141430016 |
12 |
Correct |
419 ms |
56768 KB |
Output is correct - L = 128282880 |
13 |
Correct |
455 ms |
56032 KB |
Output is correct - L = 103880448 |
14 |
Correct |
492 ms |
55616 KB |
Output is correct - L = 81555968 |
15 |
Correct |
169 ms |
19592 KB |
Output is correct - L = 188928 |
16 |
Correct |
167 ms |
19440 KB |
Output is correct - L = 192256 |
17 |
Correct |
167 ms |
19584 KB |
Output is correct - L = 187136 |
18 |
Correct |
492 ms |
55696 KB |
Output is correct - L = 134695680 |
19 |
Correct |
478 ms |
55832 KB |
Output is correct - L = 64000000 |
20 |
Correct |
480 ms |
56144 KB |
Output is correct - L = 64000000 |
21 |
Correct |
484 ms |
55872 KB |
Output is correct - L = 128282624 |
22 |
Correct |
484 ms |
55512 KB |
Output is correct - L = 64919552 |
23 |
Correct |
494 ms |
55616 KB |
Output is correct - L = 65092352 |
24 |
Correct |
488 ms |
55400 KB |
Output is correct - L = 66272768 |
25 |
Correct |
482 ms |
55400 KB |
Output is correct - L = 66663424 |
26 |
Correct |
482 ms |
55304 KB |
Output is correct - L = 65253376 |
27 |
Correct |
518 ms |
55128 KB |
Output is correct - L = 67859200 |