# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
435610 | 2qbingxuan | Navigation 2 (JOI21_navigation2) | C++17 | 1516 ms | 1036 KiB |
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 "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
pair<int,int> moves[4] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
} // namespace
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
auto ok = [N](int x, int y){ return x >= 0 && x < N && y >= 0 && y < N; };
vector<vector<int>> nxt(N, vector<int>(N));
for (int i = 0, prod = 1; i < K; i++) {
queue<pair<int,int>> q;
vector< vector<bool> > vis(N, vector<bool>(N));
nxt[R[i]][C[i]] += 4 * prod;
vis[R[i]][C[i]] = true;
q.emplace(R[i], C[i]);
while (!q.empty()) {
auto [x, y] = q.front(); q.pop();
for (int k = 0; k < 4; k++) {
auto [dx, dy] = moves[k];
if (ok(x+dx, y+dy) && !vis[x+dx][y+dy]) {
nxt[x+dx][y+dy] += k * prod;
vis[x+dx][y+dy] = true, q.emplace(x+dx, y+dy);
}
}
}
prod *= 5;
}
vector<vector<int>> flag(N, vector<int>(N));
for (int i = 1; i+1 < N; i++) {
for (int j = 1; j+1 < N; j++) {
flag[i+1][j+1] =
flag[i-1][j-1] ^ flag[i-1][j] ^ flag[i-1][j+1] ^
flag[i][j-1] ^ flag[i][j] ^ flag[i][j+1] ^
flag[i+1][j-1] ^ flag[i+1][j] ^ nxt[i][j];
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
SetFlag(i, j, flag[i][j] + 1);
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
// int variable_example = 1;
} // namespace
std::vector<int> Bruno(int K, std::vector<int> value) {
int xs = 0;
for (int x: value) xs ^= x - 1;
std::vector<int> res(K);
for (int i = 0; i < K; i++) {
res[i] = xs % 5;
xs /= 5;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |