# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
468866 | superay | Navigation 2 (JOI21_navigation2) | C++17 | 873 ms | 836 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;
void Anna(int n, int k, vector<int> r, vector<int> c) {
for (int dx = 0; dx < 3; dx++) for (int dy = 0; dy < 3; dy++) {
vector<int> vis(9, 0), idx(9);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int t = ((i + dx) % 3) * 3 + ((j + dy) % 3);
if (t < 7 && abs(r[t] - i) <= 1 && abs(c[t] - j) <= 1) {
vis[(r[t] - i + 1) * 3 + (c[t] - j + 1)] = 1;
}
}
}
if (vis[8]) continue;
int ty = -1;
for (int i = 0; i < 9; i++) if (!vis[i]) { ty = i; break; }
int cc = 0;
for (int i = 0; i < 8; i++) if (i != ty) idx[i] = ++cc;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int t = ((i + dx) % 3) * 3 + ((j + dy) % 3), cur;
if (t < 7) {
if (abs(r[t] - i) <= 1 && abs(c[t] - j) <= 1) {
cur = idx[(r[t] - i + 1) * 3 + (c[t] - j + 1)];
} else if (c[t] > j + 1) {
cur = 8;
} else if (c[t] < j - 1) {
cur = 9;
} else if (r[t] > i + 1) {
cur = 10;
} else {
cur = 11;
}
} else if (t == 7) {
cur = 12;
} else {
cur = ty + 1;
}
SetFlag(i, j, cur);
}
}
return;
}
assert(false);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
inline int Get(int x, int y, int v, vector<int> bel) {
if (v >= 8) return v - 8;
else {
int nx = x + bel[v - 1] / 3 - 1, ny = y + bel[v - 1] % 3 - 1;
if (ny > 0) return 0;
else if (ny < 0) return 1;
else if (nx > 0) return 2;
else if (nx < 0) return 3;
else return 4;
}
}
}
vector<int> Bruno(int k, vector<int> vec) {
int f1 = -1;
for (int i = 0; i < 9; i++) if (vec[i] == 12) { f1 = i; break; }
vector<int> idx(9);
if (f1 == 7) {
idx[0] = 0;
} else if (f1 == 6) {
idx[0] = 1;
} else if (f1 == 8) {
idx[0] = 2;
} else if (f1 == 4) {
idx[0] = 3;
} else if (f1 == 3) {
idx[0] = 4;
} else if (f1 == 5) {
idx[0] = 5;
} else if (f1 == 1) {
idx[0] = 6;
} else if (f1 == 0) {
idx[0] = 7;
} else if (f1 == 2) {
idx[0] = 8;
}
idx[1] = idx[0] / 3 * 3 + (idx[0] % 3 + 1) % 3;
idx[2] = idx[0] / 3 * 3 + (idx[0] % 3 + 2) % 3;
idx[3] = (idx[0] + 3) % 9;
idx[4] = idx[3] / 3 * 3 + (idx[3] % 3 + 1) % 3;
idx[5] = idx[3] / 3 * 3 + (idx[3] % 3 + 2) % 3;
idx[6] = (idx[3] + 3) % 9;
idx[7] = idx[6] / 3 * 3 + (idx[6] % 3 + 1) % 3;
idx[8] = idx[6] / 3 * 3 + (idx[6] % 3 + 2) % 3;
int ty = -1;
for (int i = 0; i < 9; i++) if (idx[i] == 8) ty = vec[i] - 1;
vector<int> bel(8);
for (int i = 0; i < 8; i++) bel[i] = i;
bel.erase(find(bel.begin(), bel.end(), ty));
vector<int> ret(7);
for (int i = 0; i < 9; i++) if (idx[i] < 7) {
ret[idx[i]] = Get(i / 3 - 1, i % 3 - 1, vec[i], bel);
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |