# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83652 | charlies_moo | Spirale (COCI18_spirale) | C++14 | 22 ms | 636 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 <fstream>
#include <iostream>
using namespace std;
int main()
{
// initialize
istream &fin = cin;
ostream &fout = cout;
// fin.open("spiral.in", ios::in);
// fout.open("spiral.out", ios::out);
// pretreatment
int x = 49, y = 49, temp = 1;
int cw[99][99] = {0};
cw[49][49] = 1;
for (int i = 0; i < 49; i++)
{
// up 1
x--; cw[x][y] = ++temp;
// right n+1
for (int j = 0; j < 2 * i + 1; j++)
{
y++;
cw[x][y] = ++temp;
}
// down n+2
for (int j = 0; j < 2 * i + 2; j++)
{
x++;
cw[x][y] = ++temp;
}
// left n+2
for (int j = 0; j < 2 * i + 2; j++)
{
y--;
cw[x][y] = ++temp;
}
// up n + 2
for (int j = 0; j < 2 * i + 2; j++)
{
x--;
cw[x][y] = ++temp;
}
}
x = 49, y = 49, temp = 1;
int ccw[99][99] = {0};
ccw[49][49] = 1;
for (int i = 0; i < 49; i++)
{
// up 1
x--; ccw[x][y] = ++temp;
// left n+1
for (int j = 0; j < 2 * i + 1; j++)
{
y--;
ccw[x][y] = ++temp;
}
// down n+2
for (int j = 0; j < 2 * i + 2; j++)
{
x++;
ccw[x][y] = ++temp;
}
// right n+2
for (int j = 0; j < 2 * i + 2; j++)
{
y++;
ccw[x][y] = ++temp;
}
// up n + 2
for (int j = 0; j < 2 * i + 2; j++)
{
x--;
ccw[x][y] = ++temp;
}
}
int n, m, k;
fin >> n >> m >> k;
int sx[k];
int sy[k];
int t[k];
for (int i = 0; i < k; i++)
{
int a, b;
fin >> a >> b >> t[i];
sx[i] = a-1;
sy[i] = b-1;
}
// process
int out[n][m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
int mini = 100000;
for (int l = 0; l < k; l++)
{
if (t[l] == 0)
{
int temp = cw[i - sx[l] + 49][j - sy[l] + 49];
if (temp < mini)
mini = temp;
}
else
{
int temp = ccw[i - sx[l] + 49][j - sy[l] + 49];
if (temp < mini)
mini = temp;
}
}
fout << mini << " ";
}
fout << endl;
}
// debug
// for (int i = 0; i < 99; i++)
// {
// for (int j = 0; j < 99; j++)
// {
// cout << cw[i][j] << " ";
// }
// cout << endl;
// }
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |