# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1210704 | emptypringlescan | Navigation 2 (JOI21_navigation2) | C++17 | 0 ms | 840 KiB |
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
pair<int,int> grid[105][105];
int val[105][105];
} // namespace
void Anna(int n, int k, std::vector<int> r, std::vector<int> c) {
for(int i=0; i<105; i++){
for(int j=0; j<105; j++){
grid[i][j]={-1,-1};
val[i][j]=0;
}
}
for(int i=0; i<7; i++){
for(int a=0; a<n; a+=2){
for(int b=i%4; b<n; b+=4){
if(grid[a][b].first==-1) grid[a][b].first=i;
else grid[a][b].second=i;
}
for(int b=(i+2)%4; b<n; b+=4){
if(grid[a+1][b].first==-1) grid[a+1][b].first=i;
else grid[a+1][b].second=i;
}
}
}
for(int i=0; i<7; i++){
for(int a=0; a<n; a++){
for(int b=0; b<n; b++){
if(grid[a][b].first==i){
if(a<r[i]&&b<=c[i]) val[a][b]+=2;
else if(a<=r[i]&&b>c[i]) val[a][b]+=1;
else if(a>r[i]&&b>=c[i]) val[a][b]+=3;
else if(a>=r[i]&&b<c[i]) val[a][b]+=0;
else val[a][b]+=4;
}
else if(grid[a][b].second==i){
if(a<r[i]&&b<=c[i]) val[a][b]+=2*5;
else if(a<=r[i]&&b>c[i]) val[a][b]+=1*5;
else if(a>r[i]&&b>=c[i]) val[a][b]+=3*5;
else if(a>=r[i]&&b<c[i]) val[a][b]+=0*5;
else val[a][b]+=4*5;
}
}
}
}
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(grid[i][j].second==-1){
val[i][j]+=5*((i%2)*4+j%4);
val[i][j]+=25;
}
SetFlag(i,j,val[i][j]+1);
}
}
}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
pair<int,int> grid[105][105];
int dx[9]={-1,-1,-1,0,0,0,1,1,1},dy[9]={-1,0,1,-1,0,1,-1,0,1};
} // namespace
std::vector<int> Bruno(int K, std::vector<int> arr) {
for(int i=0; i<9; i++) arr[i]--;
for(int i=0; i<105; i++){
for(int j=0; j<105; j++){
grid[i][j]={-1,-1};
}
}
int n=100;
for(int i=0; i<7; i++){
for(int a=0; a<n; a+=2){
for(int b=i%4; b<n; b+=4){
if(grid[a][b].first==-1) grid[a][b].first=i;
else grid[a][b].second=i;
}
for(int b=(i+2)%4; b<n; b+=4){
if(grid[a+1][b].first==-1) grid[a+1][b].first=i;
else grid[a+1][b].second=i;
}
}
}
pair<int,int> pos={-1,-1};
for(int i=0; i<9; i++){
if(arr[i]>=25){
arr[i]-=25;
int hmm=arr[i]/5;
arr[i]%=5;
pos.first=((hmm/4)-dx[i])%2;
if(pos.first<0) pos.first+=2;
pos.second=((hmm%4)-dy[i])%4;
if(pos.second<0) pos.second+=4;
}
}
assert(pos.first!=-1);
pos.first+=2; pos.second+=4;
vector<int> ret(7);
ret[grid[pos.first][pos.second].first]=arr[4]%5;
if(grid[pos.first][pos.second].second!=-1){
ret[grid[pos.first][pos.second].second]=arr[4]/5;
}
for(int i=0; i<7; i++){
vector<pair<int,int> > is;
for(int j=0; j<9; j++){
int nx=pos.first+dx[j],ny=pos.second+dy[j];
if(grid[nx][ny].first==i) is.push_back({j,arr[j]%5});
else if(grid[nx][ny].second==i) is.push_back({j,arr[j]/5});
}
if((int)is.size()==1) continue;
else if((int)is.size()==2){
assert(is[0].first==1&&is[1].first==7);
if(is[0].second==is[1].second) ret[i]=is[0].second;
else if(is[0].second==4) ret[i]=3;
else if(is[1].second==4) ret[i]=2;
else if(is[0].second==2&&is[1].second==3) ret[i]=4;
else if(is[0].second==2) ret[i]=is[1].second;
else if(is[0].second==1) ret[i]=is[0].second;
}
else{
assert((int)is.size()==3);
if(is[0].first==0){
if(is[1].second==2||is[1].second==3||is[1].second==0) ret[i]=is[1].second;
else if(is[0].second==2&&is[2].second==0) ret[i]=4;
else ret[i]=is[1].second;
}
else{
if(is[1].second==2||is[1].second==3||is[1].second==1) ret[i]=is[1].second;
else if(is[0].second==1&&is[2].second==3) ret[i]=4;
else ret[i]=is[1].second;
}
}
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |