# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
213129 |
2020-03-25T03:54:09 Z |
EntityIT |
None (JOI16_snowy) |
C++14 |
|
31 ms |
2156 KB |
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
#include "Anyalib.h"
namespace {
inline int nxt(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int prv(int i, int n) { return !i ? n - 1 : i - 1; }
int n;
vector<vector<pair<int, int> > > gr;
vector<int> group;
array<int, 10> nEle;
void dfs(int u, int pr, int iGroup) {
group[u] = iGroup;
++nEle[iGroup];
for (const auto &v : gr[u]) if (v.first ^ pr) dfs(v.first, u, nxt(iGroup, 10) );
}
int mnGroup;
vector<int> pos;
}
void InitAnya(int N, int A[], int B[]) {
n = N;
gr.assign(n, {} );
for (int i = 0; i < n - 1; ++i) {
gr[ A[i] ].emplace_back(B[i], i);
gr[ B[i] ].emplace_back(A[i], i);
}
group.assign(n, -1);
fill(all(nEle), 0);
dfs(0, -1, 0);
mnGroup = (int)(min_element(all(nEle) ) - nEle.begin() );
pos.assign(n, -1);
for (int u = 0, curPos = 0; u < n; curPos += group[u] ^ mnGroup ? 1 : 9, ++u) pos[u] = curPos;
}
void Anya(int C[]) {
function<void(int, int, int, int)> setBit = [&](int u, int pr, int cur, int prv) {
if (u) {
if (group[u] ^ mnGroup) Save(pos[u], prv);
else {
for (int i = 0; i < 9; ++i) Save(pos[u] + i, cur >> i & 1);
}
}
for (const auto &v : gr[u]) if (v.first ^ pr) setBit(v.first, u, cur + C[v.second], C[v.second]);
};
setBit(0, -1, 0, -1);
}
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
#include "Borislib.h"
namespace {
inline int nxt(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int prv(int i, int n) { return !i ? n - 1 : i - 1; }
int n;
vector<vector<pair<int, int> > > gr;
vector<int> group, par;
array<int, 10> nEle;
void dfs(int u, int pr, int iGroup) {
group[u] = iGroup;
par[u] = pr;
++nEle[iGroup];
for (const auto &v : gr[u]) if (v.first ^ pr) dfs(v.first, u, nxt(iGroup, 10) );
}
int mnGroup;
vector<int> pos;
}
void InitBoris(int N , int A[] , int B[]) {
n = N;
gr.assign(n, {} );
for (int i = 0; i < n - 1; ++i) {
gr[ A[i] ].emplace_back(B[i], i);
gr[ B[i] ].emplace_back(A[i], i);
}
group.assign(n, -1);
par.assign(n, -1);
fill(all(nEle), 0);
dfs(0, -1, 0);
mnGroup = (int)(min_element(all(nEle) ) - nEle.begin() );
pos.assign(n, -1);
for (int u = 0, curPos = 0; u < n; curPos += group[u] ^ mnGroup ? 1 : 9, ++u) pos[u] = curPos;
}
int Boris(int city) {
int ret = 0;
for (; city && group[city] ^ mnGroup; city = par[city]) ret += Ask(pos[city]);
if (city) {
for (int i = 0; i < 9; ++i) if (Ask(pos[city] + i) ) ret += 1 << i;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
880 KB |
Output is correct |
2 |
Correct |
10 ms |
988 KB |
Output is correct |
3 |
Correct |
11 ms |
1220 KB |
Output is correct |
4 |
Correct |
13 ms |
1208 KB |
Output is correct |
5 |
Correct |
15 ms |
1336 KB |
Output is correct |
6 |
Correct |
15 ms |
1280 KB |
Output is correct |
7 |
Correct |
15 ms |
1336 KB |
Output is correct |
8 |
Correct |
15 ms |
1440 KB |
Output is correct |
9 |
Correct |
15 ms |
1464 KB |
Output is correct |
10 |
Correct |
15 ms |
1336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1464 KB |
Output is correct |
2 |
Correct |
16 ms |
1484 KB |
Output is correct |
3 |
Correct |
16 ms |
1376 KB |
Output is correct |
4 |
Correct |
16 ms |
1324 KB |
Output is correct |
5 |
Correct |
16 ms |
1296 KB |
Output is correct |
6 |
Correct |
16 ms |
1452 KB |
Output is correct |
7 |
Correct |
16 ms |
1444 KB |
Output is correct |
8 |
Correct |
17 ms |
1452 KB |
Output is correct |
9 |
Correct |
16 ms |
1300 KB |
Output is correct |
10 |
Correct |
16 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
2032 KB |
Output is correct |
2 |
Correct |
26 ms |
1864 KB |
Output is correct |
3 |
Correct |
27 ms |
1864 KB |
Output is correct |
4 |
Correct |
26 ms |
2048 KB |
Output is correct |
5 |
Correct |
26 ms |
1884 KB |
Output is correct |
6 |
Correct |
26 ms |
1864 KB |
Output is correct |
7 |
Correct |
26 ms |
1896 KB |
Output is correct |
8 |
Correct |
26 ms |
1888 KB |
Output is correct |
9 |
Correct |
26 ms |
1888 KB |
Output is correct |
10 |
Correct |
26 ms |
1888 KB |
Output is correct |
11 |
Correct |
27 ms |
1792 KB |
Output is correct |
12 |
Correct |
25 ms |
1864 KB |
Output is correct |
13 |
Correct |
26 ms |
1888 KB |
Output is correct |
14 |
Correct |
26 ms |
1864 KB |
Output is correct |
15 |
Correct |
26 ms |
2116 KB |
Output is correct |
16 |
Correct |
26 ms |
1892 KB |
Output is correct |
17 |
Correct |
26 ms |
1896 KB |
Output is correct |
18 |
Correct |
26 ms |
1884 KB |
Output is correct |
19 |
Correct |
26 ms |
1880 KB |
Output is correct |
20 |
Correct |
26 ms |
1888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
2060 KB |
Output is correct |
2 |
Correct |
27 ms |
2072 KB |
Output is correct |
3 |
Correct |
26 ms |
2064 KB |
Output is correct |
4 |
Correct |
26 ms |
1888 KB |
Output is correct |
5 |
Correct |
28 ms |
1900 KB |
Output is correct |
6 |
Correct |
25 ms |
1932 KB |
Output is correct |
7 |
Correct |
28 ms |
1860 KB |
Output is correct |
8 |
Correct |
26 ms |
1984 KB |
Output is correct |
9 |
Correct |
28 ms |
1904 KB |
Output is correct |
10 |
Correct |
24 ms |
1936 KB |
Output is correct |
11 |
Correct |
28 ms |
1912 KB |
Output is correct |
12 |
Correct |
26 ms |
1852 KB |
Output is correct |
13 |
Correct |
28 ms |
1920 KB |
Output is correct |
14 |
Correct |
28 ms |
1908 KB |
Output is correct |
15 |
Correct |
28 ms |
1912 KB |
Output is correct |
16 |
Correct |
24 ms |
1916 KB |
Output is correct |
17 |
Correct |
28 ms |
1908 KB |
Output is correct |
18 |
Correct |
28 ms |
1912 KB |
Output is correct |
19 |
Correct |
27 ms |
1908 KB |
Output is correct |
20 |
Correct |
27 ms |
1912 KB |
Output is correct |
21 |
Correct |
26 ms |
1908 KB |
Output is correct |
22 |
Correct |
27 ms |
1912 KB |
Output is correct |
23 |
Correct |
26 ms |
1904 KB |
Output is correct |
24 |
Correct |
27 ms |
1904 KB |
Output is correct |
25 |
Correct |
27 ms |
1860 KB |
Output is correct |
26 |
Correct |
26 ms |
1860 KB |
Output is correct |
27 |
Correct |
27 ms |
1916 KB |
Output is correct |
28 |
Correct |
29 ms |
1908 KB |
Output is correct |
29 |
Correct |
28 ms |
2052 KB |
Output is correct |
30 |
Correct |
27 ms |
2156 KB |
Output is correct |
31 |
Correct |
27 ms |
1908 KB |
Output is correct |
32 |
Correct |
26 ms |
1792 KB |
Output is correct |
33 |
Correct |
28 ms |
1908 KB |
Output is correct |
34 |
Correct |
24 ms |
1940 KB |
Output is correct |
35 |
Correct |
24 ms |
1936 KB |
Output is correct |
36 |
Correct |
31 ms |
1900 KB |
Output is correct |
37 |
Correct |
26 ms |
1928 KB |
Output is correct |
38 |
Correct |
30 ms |
1900 KB |
Output is correct |
39 |
Correct |
25 ms |
1928 KB |
Output is correct |
40 |
Correct |
25 ms |
1936 KB |
Output is correct |
41 |
Correct |
24 ms |
1932 KB |
Output is correct |
42 |
Correct |
24 ms |
1792 KB |
Output is correct |
43 |
Correct |
24 ms |
1912 KB |
Output is correct |
44 |
Correct |
25 ms |
1928 KB |
Output is correct |
45 |
Correct |
24 ms |
1940 KB |
Output is correct |
46 |
Correct |
25 ms |
1856 KB |
Output is correct |
47 |
Correct |
24 ms |
1912 KB |
Output is correct |
48 |
Correct |
26 ms |
1856 KB |
Output is correct |
49 |
Correct |
25 ms |
1944 KB |
Output is correct |
50 |
Correct |
25 ms |
1864 KB |
Output is correct |