# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1137285 | nathan4690 | Navigation 2 (JOI21_navigation2) | C++20 | 288 ms | 880 KiB |
#include "Anna.h"
#include <bits/stdc++.h>
namespace {
int findFlag(int r, int c, int tarr, int tarc){
if(std::max(abs(tarr - r), abs(tarc - c)) <= 1){
return 3 * (tarr - r + 1) + (tarc - c + 1) + 1;
}
if(tarr < r - 1) return 10;
if(tarr > r + 1) return 12;
if(tarc < c - 1) return 13;
return 11;
}
} // namespace
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
for(int x=0;x<N;x+=3){
for(int y=0;y<N;y+=3){
for(int i=0;i<K;i++){
int vx = x + i / 3, vy = y + i % 3;
if(vx >= N || vy >= N) continue;
SetFlag(vx, vy, findFlag(vx, vy, R[i], C[i]));
}
for(int i=K;i<9;i++){
int vx = x + i / 3, vy = y + i % 3;
if(vx >= N || vy >= N) continue;
SetFlag(vx, vy, 14);
}
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
namespace {
int findDir(int code, int r, int c, int tarr, int tarc){
if(code == 10) return 3;
if(code == 12) return 2;
if(code == 11) return 0;
if(code == 13) return 1;
code--;
int rr = r + code / 3 - 1, rc = c + code % 3 - 1;
if(rr < tarr) return 3;
if(rr > tarr) return 2;
if(rc < tarc) return 1;
if(rc > tarc) return 0;
return 4;
}
} // namespace
std::vector<int> Bruno(int K, std::vector<int> value) {
bool F[3][3];
int V[3][3];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
F[i][j] = value[i * 3 + j] == 14;
V[i][j] = value[i * 3 + j];
}
}
int sx = 0, sy = 0;
if(F[0][0] && F[0][2]){sx = 1; sy = 1;}
if(F[0][1] && F[0][2]){sx = 1; sy = 0;}
if(F[0][0] && F[0][1]){sx = 1; sy = 2;}
if(F[2][0] && F[2][2]){sx = 0; sy = 1;}
if(F[2][1] && F[2][2]){sx = 0; sy = 0;}
if(F[2][1] && F[2][0]){sx = 0; sy = 2;}
if(F[1][0] && F[1][2]){sx = 2; sy = 1;}
if(F[1][1] && F[1][0]){sx = 2; sy = 2;}
if(F[1][1] && F[1][2]){sx = 2; sy = 0;}
std::vector<int> res;
for(int _=0;_<K;_++){
while(V[sx][sy] == 14){
sy = (sy == 2 ? 0 : sy + 1);
}
res.push_back(findDir(V[sx][sy], sx, sy, 1, 1));
sy = (sy == 2 ? 0 : sy + 1);
if(_ % 3 == 2) sx = (sx == 2 ? 0 : sx + 1);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |