# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896500 | danikoynov | Navigation 2 (JOI21_navigation2) | C++17 | 0 ms | 332 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 <vector>
#include<bits/stdc++.h>
using namespace std;
namespace
{
int FunctionExample(int r, int c, int K)
{
return (r + c) % K + 1;
}
} // namespace
const int maxn = 310;
int value[maxn][maxn];
pair < int, int > remain[7] = {{0, 1}, {0, 2}, {1, 0}, {1, 1}, {1, 2}, {2, 0}, {2, 1}};
map < pair < int, int >, int > ctc;
void Anna(int N, int K, std::vector<int> R, std::vector<int> C)
{
ctc[{-1, -1}] = 0;
ctc[{-1, 0}] = 1;
ctc[{-1, 1}] = 2;
ctc[{0, -1}] = 3;
ctc[{0, 0}] = 4;
ctc[{0, 1}] = 5;
ctc[{1, -1}] = 6;
ctc[{1, 0}] = 7;
ctc[{1, 1}] = 8;
for (int i = 0; i < N; i ++)
for (int j = 0; j < N; j ++)
value[i][j] = 0;
for (int i = 0; i < N; i ++)
{
for (int j = 0; j < N; j ++)
{
if (i % 3 == 0 && j % 3 == 0)
{
value[i][j] = 13;
}
else
{
for (int f = 0; f < 7; f ++)
{
if ((i - remain[f].first) % 3 != 0 || (j - remain[f].second) % 3 != 0)
continue;
if (abs(R[f] - i) <= 1 && abs(C[f] - j) <= 1)
{
pair < int, int > cell = {R[f] - i, C[f] - j};
value[i][j] = ctc[cell];
}
else
{
if (R[f] - i > 1)
value[i][j] = 9;
else
if (R[f] - i < 1)
value[i][j] = 10;
else
if (C[f] - j > 1)
value[i][j] = 11;
else
if (C[f] - j < 1)
value[i][j] = 12;
}
}
}
}
}
for (int i = 0; i < N; i ++)
for (int j = 0; j < N; j ++)
SetFlag(i, j, value[i][j] + 1);
/**for (int i = 0; i < N; i ++, cout << endl)
for (int j = 0; j < N; j ++)
cout << value[i][j] << " ";
cout << endl;*/
}
#include "Bruno.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
namespace
{
int variable_example = 1;
} // namespace
pair < int, int > rem[7] = {{0, 1}, {0, 2}, {1, 0}, {1, 1}, {1, 2}, {2, 0}, {2, 1}};
pair < int, int > neib[9] = {{-1, -1}, {-1, 0}, {-1, 1},
{0, -1}, {0, 0}, {0, 1},
{1, -1}, {1, 0}, {1, 1}
};
map < pair < int, int >, int > cell_to_code;
int mark[10];
std::vector<int> Bruno(int K, std::vector<int> value)
{
cell_to_code[ {-1, -1}] = 0;
cell_to_code[ {-1, 0}] = 1;
cell_to_code[ {-1, 1}] = 2;
cell_to_code[ {0, -1}] = 3;
cell_to_code[ {0, 0}] = 4;
cell_to_code[ {0, 1}] = 5;
cell_to_code[ {1, -1}] = 6;
cell_to_code[ {1, 0}] = 7;
cell_to_code[ {1, 1}] = 8;
///cout << "BRUNO" << endl;
for (int i = 0; i < 9; i ++)
value[i] --;
pair < int, int > base;
for (int i = 0; i < 9; i ++)
if (value[i] == 13)
base = neib[i];
for (int i = 0; i < 9; i ++)
{
mark[i] = -1;
}
for (int i = 0; i < 7; i ++)
{
pair < int, int > cell = base;
cell.first += rem[i].first;
cell.second += rem[i].second;
cell.first %= 3;
cell.second %= 3;
if (cell.first == 2)
cell.first = -1;
if (cell.second == 2)
cell.second = -1;
mark[cell_to_code[cell]] = i;
}
vector < int > res(K);
for (int i = 0; i < 9; i ++)
{
if (mark[i] == -1)
continue;
if (value[i] == 9)
res[mark[i]] = 2;
else if (value[i] == 10)
res[mark[i]] = 3;
else if (value[i] == 11)
res[mark[i]] = 0;
else if (value[i] == 12)
res[mark[i]] = 1;
else
{
pair < int, int > cell = neib[i];
cell.first += neib[value[i]].first;
cell.second += neib[value[i]].second;
if (cell.first == 0 && cell.second == 0)
res[mark[i]] = 4;
else if (cell.first > 0)
res[mark[i]] = 2;
else if (cell.first < 0)
res[mark[i]] = 3;
else if (cell.second > 0)
res[mark[i]] = 0;
else if (cell.second < 0)
res[mark[i]] = 1;
}
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |