#include "Encoder.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
static lli aux=0;
void dfs(int n , int par, vector<vector<int>> &adj, vector<pair<lli,lli>> &range ){
lli ini=aux;
// deb(n);
// deb(aux);
// deb(par);
aux++;
for(int x: adj[n]){
if(x==par) continue;
// deb(x);
dfs(x, n, adj, range);
}
lli fin=aux;
range[n]={ini, fin-1};
}
void Encode(int N, int A[], int B[])
{
vector<vector<int>> adj (N);
for(int i=0; i<N-1; ++i){
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
}
vector<pair<lli,lli>> range (N);
dfs(0,-1,adj, range);
for (int i = 0; i < N; ++i) {
lli ini=range[i].first;
lli fin=range[i].second;
// deb(i);
// deb(ini);
// deb(fin);
Code(i, ini*250000+fin);
}
}
#include "Device.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
void InitDevice()
{
}
int Answer(long long S, long long T)
{
lli finS=S%250000;
lli iniS= (S-finS)/250000;
lli finT=T%250000;
lli iniT=(T-finT)/250000;
if(iniT <= iniS && finS <= finT){
return 0;
}
if(iniS <= iniT && finT <= finS){
return 1;
}
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4880 KB |
Output is correct |
2 |
Correct |
1 ms |
4892 KB |
Output is correct |
3 |
Correct |
1 ms |
4880 KB |
Output is correct |
4 |
Correct |
2 ms |
4876 KB |
Output is correct |
5 |
Correct |
2 ms |
4880 KB |
Output is correct |
6 |
Correct |
1 ms |
4892 KB |
Output is correct |
7 |
Correct |
1 ms |
4892 KB |
Output is correct |
8 |
Correct |
1 ms |
4896 KB |
Output is correct |
9 |
Correct |
1 ms |
4892 KB |
Output is correct |
10 |
Correct |
2 ms |
4888 KB |
Output is correct |
11 |
Correct |
2 ms |
4892 KB |
Output is correct |
12 |
Correct |
1 ms |
4888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
12444 KB |
Output is correct - L = 174750699 |
2 |
Correct |
125 ms |
12440 KB |
Output is correct - L = 174500698 |
3 |
Correct |
120 ms |
12500 KB |
Output is correct - L = 174750699 |
4 |
Correct |
121 ms |
12452 KB |
Output is correct - L = 174750699 |
5 |
Partially correct |
268 ms |
33380 KB |
Output is partially correct - L = 62499999999 |
6 |
Partially correct |
266 ms |
33416 KB |
Output is partially correct - L = 62499999999 |
7 |
Partially correct |
263 ms |
33424 KB |
Output is partially correct - L = 62499999999 |
8 |
Partially correct |
264 ms |
33180 KB |
Output is partially correct - L = 62499999999 |
9 |
Partially correct |
240 ms |
33988 KB |
Output is partially correct - L = 62499999999 |
10 |
Partially correct |
238 ms |
34176 KB |
Output is partially correct - L = 62499999999 |
11 |
Partially correct |
238 ms |
34200 KB |
Output is partially correct - L = 62499999999 |
12 |
Partially correct |
241 ms |
34048 KB |
Output is partially correct - L = 62499999999 |
13 |
Partially correct |
250 ms |
33852 KB |
Output is partially correct - L = 62499999999 |
14 |
Partially correct |
261 ms |
33680 KB |
Output is partially correct - L = 62499999999 |
15 |
Correct |
124 ms |
12396 KB |
Output is correct - L = 174750699 |
16 |
Correct |
121 ms |
12380 KB |
Output is correct - L = 174750699 |
17 |
Correct |
124 ms |
12448 KB |
Output is correct - L = 174750699 |
18 |
Partially correct |
255 ms |
33540 KB |
Output is partially correct - L = 62499999999 |
19 |
Partially correct |
265 ms |
33496 KB |
Output is partially correct - L = 62499999999 |
20 |
Partially correct |
256 ms |
33592 KB |
Output is partially correct - L = 62499999999 |
21 |
Partially correct |
254 ms |
33664 KB |
Output is partially correct - L = 62499999999 |
22 |
Partially correct |
261 ms |
33528 KB |
Output is partially correct - L = 62499999999 |
23 |
Partially correct |
269 ms |
33612 KB |
Output is partially correct - L = 62499999999 |
24 |
Partially correct |
260 ms |
33600 KB |
Output is partially correct - L = 62499999999 |
25 |
Partially correct |
265 ms |
33616 KB |
Output is partially correct - L = 62499999999 |
26 |
Partially correct |
277 ms |
33320 KB |
Output is partially correct - L = 62499999999 |
27 |
Partially correct |
273 ms |
33448 KB |
Output is partially correct - L = 62499999999 |