# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1227648 | KindaGoodGames | Navigation 2 (JOI21_navigation2) | C++20 | 707 ms | 590144 KiB |
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define tiiii tuple<int,int,int,int>
namespace {
int INF = numeric_limits<int>::max()/2;
int FunctionExample(int r, int c, int K) {
return (r + c) % K + 1;
}
} // namespace
void Anna(int n, int K, std::vector<int> R, std::vector<int> C) {
vector<vector<short>> result(n,vector<short>(n,1));
vector<bitset<100>> vis(n);
vector<vector<int>> mode(n, vector<int>(n,INF));
for(int k = 0; k < K; k++){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
mode[i][j] = INF;
vis[i][j] = false;
}
}
queue<tiiii> q;
q.push({0, 5, R[k], C[k]});
auto psh = [&](int d, int m, int r, int c){
if(r < 0 || r >= n) return;
if(c < 0 || c >= n) return;
if(vis[r][c]) return;
q.push({d,m,r,c});
};
//BFS
while(q.size()){
int d,m,r,c;
tie(d,m,r,c) = q.front(); q.pop();
vis[r][c] = true;
if(m != 5)mode[r][c] = m;
/*
> : 0
< : 1
v : 2
^ : 3
*/
psh(d+1,1,r,c+1);
psh(d+1,0,r,c-1);
psh(d+1,3,r+1,c);
psh(d+1,2,r-1,c);
}
for (int r = 0; r < n; r++) {
for (int c = 0; c < n; c++) {
if(mode[r][c] != INF) result[r][c] += ((1<<(2*k)) * mode[r][c]);
}
}
}
for (int r = 0; r < n; r++) {
for (int c = 0; c < n; c++) {
SetFlag(r,c,result[r][c]);
}
}
}
#include "Bruno.h"
#include <vector>
namespace {
int toInd(int dr, int dc){
dr += 1;
dc += 1;
return (dr*3)+dc;
}
int conv(int v, int k){
v >>= (2*k);
v %= 4;
return v;
}
} // namespace
std::vector<int> Bruno(int K, std::vector<int> value) {
std::vector<int> res(K, 0);
for(int i = 0; i < value.size(); i++){
value[i]--;
}
for (int i = 0; i < K; i++) {
bool isGoal = true;
if(conv(value[toInd(0,-1)],i) != 0) {
isGoal = false;
}
if(conv(value[toInd(0,1)],i) != 1) {
isGoal = false;
}
if(conv(value[toInd(-1,0)],i) != 2) {
isGoal = false;
}
if(conv(value[toInd(1,0)],i) != 3) {
isGoal = false;
}
if(isGoal){
res[i] = 4;
}else{
int cur = conv(value[4],i);
res[i] = cur;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |