# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
936184 |
2024-03-01T10:24:54 Z |
nguyentunglam |
City (JOI17_city) |
C++17 |
|
126 ms |
21336 KB |
#include "Encoder.h"
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
namespace {
const int NN = 3e5 + 10;
vector<int> adj[NN];
int n;
bool vis[NN];
int cnt = -1;
}
void dfs(int u, int p) {
vis[u] = 1;
int st = ++cnt;
for(int &v : adj[u]) if (v != p) dfs(v, u);
int diff = 1, deg = 0;
int old = cnt;
while (diff < cnt - st) diff *= 2, deg++;
cnt = st + diff;
assert(st <= 19 * n);
long long code = st * 19 + deg;
// cout << st << " " << old << " " << cnt << " " << deg << " " << u << endl;
assert(code < (1 << 27));
Code(u, code);
}
void Encode(int N, int A[], int B[])
{
n = N;
for(int i = 0; i < N - 1; i++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++) if (!vis[i]) dfs(i, i);
}
#include "Device.h"
#include<bits/stdc++.h>
using namespace std;
void InitDevice()
{
}
int Answer(long long S, long long T)
{
long long st_x = S / 19;
long long ed_x = st_x + (1 << (S % 19));
long long st_y = T / 19;
long long ed_y = st_y + (1 << (T % 19));
// cout << st_x << " " << ed_x << endl;
// cout << st_y << " " << ed_y << endl;
if (st_x <= st_y && st_y <= ed_x) return 1;
if (st_y <= st_x && st_x <= ed_y) return 0;
return 2;
}
Compilation message
Encoder.cpp: In function 'void dfs(int, int)':
Encoder.cpp:24:7: warning: unused variable 'old' [-Wunused-variable]
24 | int old = cnt;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13580 KB |
Output is correct |
2 |
Correct |
3 ms |
13080 KB |
Output is correct |
3 |
Correct |
3 ms |
13096 KB |
Output is correct |
4 |
Correct |
2 ms |
13072 KB |
Output is correct |
5 |
Correct |
3 ms |
13080 KB |
Output is correct |
6 |
Correct |
3 ms |
13084 KB |
Output is correct |
7 |
Correct |
2 ms |
13068 KB |
Output is correct |
8 |
Correct |
2 ms |
13080 KB |
Output is correct |
9 |
Correct |
2 ms |
13068 KB |
Output is correct |
10 |
Correct |
3 ms |
13080 KB |
Output is correct |
11 |
Correct |
3 ms |
13072 KB |
Output is correct |
12 |
Correct |
2 ms |
13072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
20648 KB |
Output is correct - L = 175256 |
2 |
Runtime error |
10 ms |
21336 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |