# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
144785 | tnbs10 | Spirale (COCI18_spirale) | C++14 | 135 ms | 632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// HONI 17/18, kolo 5, zad.5 - spirale
// http://hsin.hr/honi/arhiva/2017_2018/kolo5_zadaci.pdf
#include <bits/stdc++.h>
#define MAXN 200
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
using namespace std;
ll n, m, k, x, y, t, a[MAXN][MAXN], sred = 70, smjer, sm[5];
void print(ll arr[MAXN][MAXN], int r, int s) {
for (int i = sred; i < sred + r; i++) {
for (int j = sred; j < sred + s; ++j) {
cout << a[i][j] << " ";
}
cout << "\n";
}
}
void spirc(int x, int y, int t) {
int curr = 1; ll prati = 1; smjer = 0;
while (x > 15 and x < 175 and y > 15 and y < 175) {
/*cout << x << " " << y << " " << " -> " << prati << "\n";*/
if (!a[x][y]) a[x][y] = prati;
else a[x][y] = min(prati, a[x][y]);
if (smjer % 4 == 0) x--;
else if (smjer % 4 == 1 and !t) y++;
else if (smjer % 4 == 1) y--;
else if (smjer % 4 == 2) x++;
else if (smjer % 4 == 3 and !t) y--;
else y++;
if (!--sm[smjer % 4]) {
sm[smjer % 4] = curr + 2;
curr = sm[++smjer % 4];
}
++prati;
}
}
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
for (int i = 0; i < k; i++) {
cin >> x >> y >> t;
x--; y--;
sm[0] = sm[1] = 1;
sm[2] = sm[3] = 2;
spirc(x + sred, y + sred, t);
}
print(a, n, m);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |