# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972706 | nguyentunglam | Navigation 2 (JOI21_navigation2) | C++17 | 8 ms | 924 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 <vector>
#include<bits/stdc++.h>
using namespace std;
namespace {
int next_cnt (int x) {
if (x == 9) return 1;
return x + 1;
}
} // namespace
void Anna(int n, int k, std::vector<int> r, std::vector<int> c) {
int start = 1;
vector<vector<int> > label(n, vector<int> (n));
vector<vector<int> > ret(n, vector<int> (n));
for(int i = 0; i < n; i++) {
int cnt = start;
for(int j = 0; j < n; j++) {
label[i][j] = cnt;
cnt = next_cnt(cnt);
}
start += 3;
if (start > 9) start -= 9;
}
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if (label[i][j] <= k) {
int x = r[label[i][j] - 1];
int y = c[label[i][j] - 1];
ret[i][j] = 0;
if (j + 1 < y) ret[i][j] = 1;
if (j - 1 > y) ret[i][j] = 2;
if (i + 1 < x) ret[i][j] = 3;
if (i - 1 > x) ret[i][j] = 4;
if (ret[i][j] == 0) {
ret[i][j] = 4 + (x - i + 1) * 3 + y - j + 2;
}
// if (i == 1 && j == 0) cout << x << " " << y << endl;
}
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if (label[i][j] == 9) ret[i][j] = 13;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if (label[i][j] == 8) ret[i][j] = 1;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) SetFlag(i, j, ret[i][j]);
// for(int i = 0; i < n; i++) {
// for(int j = 0; j < n; j++) cout << ret[i][j] << " ";
// cout << endl;
// }
// exit(0);
}
#include "Bruno.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
namespace {
//int next_cnt (int x) {
// if (x == 9) return 1;
// return x + 1;
//}
int variable_example = 1;
} // namespace
int Move (int i, int j, int x, int y) {
if (j < y) return 0;
if (j > y) return 1;
if (i < x) return 2;
if (i > x) return 3;
return 4;
}
std::vector<int> Bruno(int k, std::vector<int> value) {
// exit(0);
vector<vector<int> > a(3, vector<int> (3));
vector<vector<int> > b(3, vector<int> (3));
vector<int> ret(k);
int cnt = 0;
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
a[i][j] = value[cnt++];
}
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if (a[i][j] == 13) {
b[i][j] = 9;
int x = i, y = j;
for(int loop = 1; loop <= 8; loop++) {
if (y + 1 < 3) y++;
else {
x++;
if (x == 3) x = 0;
y = 0;
}
b[x][y] = loop;
}
}
// exit(0);
// for(int i = 0; i < 3; i++) {
// for(int j = 0; j < 3; j++) cout << b[i][j] << " "; cout << endl;
// }
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if (b[i][j] <= 7) {
if (a[i][j] <= 4) {
ret[b[i][j] - 1] = a[i][j] - 1;
}
else {
a[i][j] -= 5;
int x = a[i][j] / 3 + i - 1;
int y = a[i][j] % 3 + j - 1;
ret[b[i][j] - 1] = Move(1, 1, x, y);
}
}
// for(int &j : ret) cout << j << " ";
// exit(0);
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |