| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 144785 | tnbs10 | Spirale (COCI18_spirale) | C++14 | 135 ms | 632 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.
// 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... | ||||
