# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
571021 | ibm2006 | Navigation 2 (JOI21_navigation2) | C++17 | 909 ms | 1580 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<bits/stdc++.h>
#include "Anna.h"
using namespace std;
typedef int ll;
void Anna(ll N, ll K, vector<ll> R, vector<ll> C) {
ll x,y,z,w,n,k,i,j,a[400][400],b[3][3]={},c[1100]={},t,l;
vector<ll> u,v;
pair<ll,ll> p[7]={{-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1}};
n=N;
k=7;
for(i=0;i<400;i++)
for(j=0;j<400;j++)
a[i][j]=0;
v=R; u=C;
for(i=0;i<k;i++)
{
v[i]++;
u[i]++;
}
x=-1; y=-1;
for(i=0;i<k;i++)
b[(v[i]+2+2-p[i].first)%3][(u[i]+2+2-p[i].second)%3]=1;
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{
if(b[i][j]==0)
{
x=i; y=j;
// printf("%lld %lld\n",x,y);
break;
}
}
if(x>=0)
break;
}
x-=3; y-=3;
for(i=x;i<=n;i+=3)
{
for(j=y;j<=n;j+=3)
{
if(i>=1&&j>=1)
a[i][j]=13;
}
}
for(l=0;l<7;l++)
{
z=x+p[l].first;
w=y+p[l].second;
for(i=z;i<=n;i+=3)
for(j=w;j<=n;j+=3)
{
if(i<1||j<1)
{
continue;
}
if((i+1)==v[l]&&(j+1)==u[l])
{
a[i][j]=5;
}
else if((i+1)==v[l]&&(j)==u[l])
{
a[i][j]=6;
}
else if((i+1)==v[l]&&(j-1)==u[l])
{
a[i][j]=7;
}
else if((i)==v[l]&&(j+1)==u[l])
{
a[i][j]=8;
}
else if((i)==v[l]&&(j)==u[l])
{
a[i][j]=9;
}
else if((i)==v[l]&&(j-1)==u[l])
{
a[i][j]=10;
}
else if((i-1)==v[l]&&(j+1)==u[l])
{
a[i][j]=11;
}
else if((i-1)==v[l]&&(j)==u[l])
{
a[i][j]=12;
}
else if((i-1)==v[l]&&(j-1)==u[l])
{
a[i][j]=13;
}
else if((j-2)>=u[l])
{
a[i][j]=2;
}
else if((j+2)<=u[l])
{
a[i][j]=1;
}
else if((i-2)>=v[l])
{
a[i][j]=4;
}
else if((i+2)<=v[l])
{
a[i][j]=3;
}
}
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
c[a[i][j]]=1;
for(i=1;i<=12;i++)
{
if(c[i]==0)
{
t=i;
break;
}
}
z=x-3; w=y-4;
for(i=z;i<=n;i+=3)
for(j=w;j<=n;j+=3)
{
if(i>=1&&j>=1)
a[i][j]=t;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
if(a[i][j]>t)
a[i][j]--;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
SetFlag(i-1,j-1,a[i][j]);
}
#include<bits/stdc++.h>
#include "Bruno.h"
using namespace std;
typedef int ll;
vector<ll> Bruno(ll K,vector<ll> value) {
ll x,y,i,j,n,k,a[110][110],z,w,t,l,x1,y1,s=0;
k=7;
pair<ll,ll> p[7]={{2,2},{2,0},{2,1},{0,1},{1,1},{1,0},{1,2}};
vector<ll> v;
v.resize(7);
n=3;
for(i=0;i<(n*n);i++)
a[i/3][i%3]=value[i];
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{
// printf("%lld ",a[i][j]);
if(a[i][j]==12)
{
x=i; y=j;
s++;
}
}
}
if(s==2)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(a[i][j]==12&&a[i][(j+2)%3]==12)
{
x=i; y=j;
}
}
}
}
t=a[(x)%3][(y+2)%3];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if(a[i][j]>=t)
a[i][j]++;
}
for(l=0;l<k;l++)
{
z=(x+p[l].first)%3;
w=(y+p[l].second)%3;
x1=z; y1=w;
if(a[z][w]==1)
{
v[l]=0;
continue;
}
else if(a[z][w]==2)
{
v[l]=1;
continue;
}
else if(a[z][w]==3)
{
v[l]=2;
continue;
}
else if(a[z][w]==4)
{
v[l]=3;
continue;
}
else if(a[z][w]==5)
{
x1++; y1++;
}
else if(a[z][w]==6)
{
x1++;
}
else if(a[z][w]==7)
{
x1++; y1--;
}
else if(a[z][w]==8)
{
y1++;
}
else if(a[z][w]==9)
{
}
else if(a[z][w]==10)
{
y1--;
}
else if(a[z][w]==11)
{
x1--; y1++;
}
else if(a[z][w]==12)
{
x1--;
}
else if(a[z][w]==13)
{
x1--; y1--;
}
if(x1==1&&y1==1)
{
v[l]=4;
continue;
}
if(x1==1)
{
if(y1>1)
{
v[l]=0;
}
else
v[l]=1;
}
else
{
if(x1>1)
{
v[l]=2;
}
else
v[l]=3;
continue;
}
}
return v;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |