# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
551909 |
2022-04-21T21:48:03 Z |
LucaDantas |
City (JOI17_city) |
C++17 |
|
197 ms |
27468 KB |
#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 1<<18;
vector<int> g[maxn];
int t, in[maxn], out[maxn];
void dfs(int u, int p) {
in[u] = ++t;
for(int v : g[u]) if(v != p)
dfs(v, u);
out[u] = t;
// printf("%d -> %d %d\n", u, in[u], out[u]);
}
void Encode(int N, int A[], int B[])
{
for(int i = 0; i < N-1; i++)
g[A[i]].push_back(B[i]), g[B[i]].push_back(A[i]);
dfs(0, -1);
for (int i = 0; i < N; ++i)
Code(i, in[i] | (out[i] << 18));
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
void InitDevice()
{
}
int Answer(long long S, long long T)
{
long long in[2], out[2];
for(int rep = 0; rep < 2; rep++, swap(S, T)) {
out[rep] = S >> 18;
in[rep] = S ^ (out[rep] << 18);
}
int vira = 0;
if(in[0] > in[1])
swap(in[0], in[1]), swap(out[0], out[1]), vira = 1;
/* printf("%lld %lld | %lld %lld\n", in[0], out[0], in[1], out[1]);
printf("%d\n\n", out[0] >= in[1] ? 1^vira : 2); */
return (out[0] >= in[1] ? 1^vira : 2);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6864 KB |
Output is correct |
2 |
Correct |
4 ms |
6800 KB |
Output is correct |
3 |
Correct |
4 ms |
6808 KB |
Output is correct |
4 |
Correct |
4 ms |
6816 KB |
Output is correct |
5 |
Correct |
3 ms |
6808 KB |
Output is correct |
6 |
Correct |
3 ms |
6816 KB |
Output is correct |
7 |
Correct |
3 ms |
6804 KB |
Output is correct |
8 |
Correct |
4 ms |
6808 KB |
Output is correct |
9 |
Correct |
4 ms |
6816 KB |
Output is correct |
10 |
Correct |
4 ms |
6808 KB |
Output is correct |
11 |
Correct |
4 ms |
6808 KB |
Output is correct |
12 |
Correct |
4 ms |
6808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
22172 KB |
Output is correct - L = 183501500 |
2 |
Correct |
197 ms |
22076 KB |
Output is correct - L = 183239355 |
3 |
Correct |
165 ms |
22280 KB |
Output is correct - L = 183501500 |
4 |
Correct |
167 ms |
22300 KB |
Output is correct - L = 183501500 |
5 |
Incorrect |
150 ms |
27468 KB |
Wrong Answer [3] |
6 |
Halted |
0 ms |
0 KB |
- |