# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417485 | maximath_1 | Navigation 2 (JOI21_navigation2) | C++17 | 799 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 <vector>
using namespace std;
vector<int> r, c;
int group(int i, int j){
return 3 * (i % 3) + j % 3;
}
int f(int i, int j){
int gt = group(i, j);
if(gt == 0) return 14; // fixed group as "compass"
if(gt == 8) return 1; // unused group
gt --;
// far cells (chebyshev distance >= 2)
if(c[gt] > j + 1) return 1;
if(c[gt] < j - 1) return 2;
if(r[gt] > i + 1) return 3;
if(r[gt] < i - 1) return 4;
// close cells (otherwise)
return 5 + 3 * (r[gt] - (i - 1)) + (c[gt] - (j - 1));
}
void Anna(int N, int K, vector<int> R, vector<int> C) {
r = R; c = C;
for(int i = 0; i < N; i ++)
for(int j = 0; j < N; j ++)
SetFlag(i, j, f(i, j));
}
#include "Bruno.h"
#include <vector>
using namespace std;
int tp[3][3];
void fill(int r, int c){ // fill tp numbering if (r, c) is compass
for(int i = -2; i <= 2; i ++)
for(int j = -2; j <= 2; j ++)
if(0 <= r + i && r + i <= 2 && 0 <= c + j && c + j <= 2){
tp[r + i][c + j] = 3 * ((i + 3) % 3) + (j + 3) % 3;
}
}
vector<int> Bruno(int K, vector<int> value) {
vector<int> ans(K, 0);
for(int i = 0; i < 3; i ++)
for(int j = 0; j < 3; j ++)
if(value[3 * i + j] == 14){
fill(i, j); break;
}
for(int i = 0; i < 3; i ++)
for(int j = 0; j < 3; j ++){
if(tp[i][j] == 0 || tp[i][j] == 8) continue;
if(value[3 * i + j] < 5)
ans[tp[i][j] - 1] = value[3 * i + j] - 1;
else{
int gt = value[3 * i + j] - 5;
int x = gt / 3, y = gt % 3;
int fi = i - 1 + x, sc = j - 1 + y;
if(sc > 1) gt = 0;
else if(sc < 1) gt = 1;
else if(fi > 1) gt = 2;
else if(fi < 1) gt = 3;
else gt = 4;
ans[tp[i][j] - 1] = gt;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |