This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dungeon2.h"
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <iostream>
template <class T>
using Vec = std::vector<T>;
using Path = Vec<std::pair<int, int>>;
Vec<Vec<int>> graph;
void Inspect(int R) {
Vec<int> ret(R + 1);
Vec<Path> nodes;
{
std::queue<Path> que;
que.push({ });
while (!que.empty()) {
const auto path = que.front();
que.pop();
nodes.push_back(path);
const auto len = (int) path.size();
if (len <= R) {
ret[len] += 1;
}
for (int i = 0; i < len; ++i) {
Move(path[i].first, 2);
}
const auto deg = NumberOfRoads();
for (int i = 1; i <= deg; ++i) {
Move(i, 2);
if (Color() == 1) {
auto new_path = path;
new_path.emplace_back(i, LastRoad());
que.push(new_path);
}
Move(LastRoad(), 2);
}
for (int i = len - 1; i >= 0; --i) {
Move(path[i].second, 2);
}
}
}
for (int src = 1; src < (int) nodes.size(); ++src) {
const auto Cur = Color();
const auto Next = 3 - Cur;
for (int i = 0; i < (int) nodes[src].size(); ++i) {
Move(nodes[src][i].first, Cur);
}
std::queue<Path> que;
que.push({ });
while (!que.empty()) {
const auto path = que.front();
que.pop();
const auto len = (int) path.size();
if (len <= R) {
ret[len] += 1;
}
for (int i = 0; i < len; ++i) {
Move(path[i].first, Next);
}
const auto deg = NumberOfRoads();
for (int i = 1; i <= deg; ++i) {
Move(i, Next);
if (Color() == Cur) {
auto new_path = path;
new_path.emplace_back(i, LastRoad());
que.push(new_path);
}
Move(LastRoad(), Next);
}
for (int i = len - 1; i >= 0; --i) {
Move(path[i].second, Next);
}
}
for (int i = (int) nodes[src].size() - 1; i >= 0; --i) {
Move(nodes[src][i].second, Next);
}
}
for (int i = 1; i <= R; ++i) {
Answer(i, ret[i] / 2);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |