# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930105 | bachhoangxuan | Navigation 2 (JOI21_navigation2) | C++17 | 563 ms | 2448 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;
namespace A{
const int Col = 13;
const int maxn = 105;
int flag[maxn][maxn];
void solve(int N,int K,vector<int> R,vector<int> C){
function<int(int,int,int,int)> g = [&](int i,int j,int x,int y){
if(j<=y-2) return 9;
if(j>=y+2) return 10;
if(i<=x-2) return 11;
if(i>=x+2) return 12;
int val=(i-x+1)*3+j-y+1+1;
return (val==9?-1:val);
};
function<bool(int)> f = [&](int d){
for(int i=0;i<N;i++) for(int j=0;j<N;j++){
int k=(i+(d/3))%3*3+(j+d%3)%3;
flag[i][j]=(k<7?g(i,j,R[k],C[k]):(k==8?Col:0));
if(flag[i][j]==-1) return false;
}
return true;
};
for(int i=0;i<9;i++) if(f(i)) break;
vector<bool> used(Col+1,0);
for(int i=0;i<N;i++){
for(int j=0;j<N;j++) used[flag[i][j]]=true;
}
int x=0;
while(used[x]) x++;
for(int i=0;i<N;i++) for(int j=0;j<N;j++){
if(flag[i][j]>x) flag[i][j]--;
if(flag[i][j]==0) flag[i][j]=x;
SetFlag(i,j,flag[i][j]);
}
}
}
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
A::solve(N,K,R,C);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace B{
const int Col = 12;
vector<int> solve(int K,vector<int> value){
vector<int> res(K,0);
int dx=-1,dy=-1;
for(int i=0;i<9;i++) if(value[i]==Col){
dx=i/3,dy=i%3;
break;
}
int X=value[dx*3+(dy+2)%3];
function<int(int,int,int,int)> f = [&](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;
};
for(int d=0;d<9;d++){
int i=(d/3+2-dx)%3,j=(d%3+2-dy)%3;
int k=i*3+j;
if(k>=7) continue;
if(value[d]>=X) value[d]++;
if(value[d]>=9) res[k]=value[d]-9;
else{
int x=d/3+(1-(value[d]-1)/3),y=d%3+(1-(value[d]-1)%3);
res[k]=f(1,1,x,y);
}
}
return res;
}
}
std::vector<int> Bruno(int K, std::vector<int> value) {
return B::solve(K,value);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |