# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
210324 |
2020-03-17T04:31:29 Z |
EntityIT |
None (JOI16_dungeon2) |
C++14 |
|
23 ms |
1400 KB |
#include "dungeon2.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }
const int LIM = 243;// 3 ^ 5
const int inf = 1e9;
mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );
vector<vector<int> > gr;
int buildTree() {
if (Color() ^ 1) {
int ret = Color();
Move(LastRoad(), ret);
return -ret;
}
int u = sz(gr); gr.emplace_back(vector<int>(NumberOfRoads() ) );
int prv = LastRoad() - 1;
for (int i = 0; i < sz(gr[u]); ++i) {
if (i ^ prv) {
Move(i + 1, 2);
int tmp = buildTree();
if (tmp < 0) gr[u][i] = tmp;
else gr[u][i] = tmp;
}
else gr[u][i] = -1;
}
if (u) Move(prv + 1, 3);
return u;
}
array<int, 5> pw3{ 1, 3, 9, 27, 81 };
int get(int a, int k) {
a /= pw3[k];
int ret = 0;
while (a % 3) ++ret, --a;
return ret;
}
void solve(int u, int k) {
int c = get(u, k) + 1;
for (int i = 0; i < sz(gr[u]); ++i) {
if (gr[u][i] >= 0) {
Move(i + 1, c);
solve(gr[u][i], k);
}
else if (gr[u][i] < -3) {
Move(i + 1, c);
int coef = Color() - 1;
gr[u][i] += pw3[k] * coef;
Move(LastRoad(), coef + 1);
}
}
if (u) Move( (int)(find(all(gr[u]), -1) - gr[u].begin() ) + 1, c);
}
void Inspect(int R) {
buildTree();
for (auto &i : gr) {
for (auto &j : i) if (j == -2) j = -LIM;
}
solve(0, 0);
solve(0, 1);
solve(0, 2);
solve(0, 3);
solve(0, 4);
vector<vector<int> > d(sz(gr), vector<int>(sz(gr), inf) );
for (int u = 0; u < sz(gr); ++u) {
d[u][u] = 0;
for (int i = 0; i < sz(gr[u]); ++i) {
if (gr[u][i] < -3) gr[u][i] += LIM;
if (gr[u][i] >= 0) d[u][ gr[u][i] ] = d[ gr[u][i] ][u] = 1;
}
}
for (int k = 0; k < sz(gr); ++k) {
for (int i = 0; i < sz(gr); ++i) {
for (int j = 0; j < sz(gr); ++j) asMn(d[i][j], d[i][k] + d[k][j]);
}
}
vector<int> ans(R);
for (int u = 0; u < sz(gr); ++u) {
for (int v = u + 1; v < sz(gr); ++v) if (d[u][v] <= R) ++ans[ d[u][v] - 1 ];
}
for (int i = 0; i < R; ++i) Answer(i + 1, ans[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
380 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
380 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
504 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
888 KB |
Output is correct |
2 |
Correct |
13 ms |
888 KB |
Output is correct |
3 |
Correct |
14 ms |
888 KB |
Output is correct |
4 |
Correct |
23 ms |
1400 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
7 ms |
632 KB |
Output is correct |
7 |
Correct |
13 ms |
888 KB |
Output is correct |
8 |
Correct |
13 ms |
888 KB |
Output is correct |
9 |
Correct |
14 ms |
888 KB |
Output is correct |
10 |
Correct |
13 ms |
888 KB |
Output is correct |
11 |
Correct |
13 ms |
888 KB |
Output is correct |
12 |
Correct |
13 ms |
888 KB |
Output is correct |
13 |
Correct |
14 ms |
1016 KB |
Output is correct |
14 |
Correct |
13 ms |
888 KB |
Output is correct |
15 |
Correct |
13 ms |
892 KB |
Output is correct |
16 |
Correct |
8 ms |
760 KB |
Output is correct |
17 |
Correct |
22 ms |
1272 KB |
Output is correct |
18 |
Correct |
23 ms |
1272 KB |
Output is correct |
19 |
Correct |
22 ms |
1272 KB |
Output is correct |