# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
237533 |
2020-06-07T08:05:05 Z |
VEGAnn |
Spirale (COCI18_spirale) |
C++14 |
|
127 ms |
512 KB |
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define i2 array<int, 2>
using namespace std;
typedef long long ll;
const int N = 110;
const int oo = 2e9;
int ans[N][N], kol, n, m, k, step;
bool mrk[N][N];
void upd(int &x, int y){
x = min(x, y);
}
void up(int &x, int &y, int tp, int len){
while (len > 0){
len--;
step++;
if (tp == 0)
x--;
else if (tp == 1)
y--;
else if (tp == 2)
x++;
else y++;
if (x >= 0 && y >= 0 && x < n && y < m && !mrk[x][y]){
mrk[x][y] = 1;
kol--;
upd(ans[x][y], step);
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m >> k;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i][j] = oo;
for (; k; k--){
int x, y, t; cin >> x >> y >> t;
x--; y--;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
mrk[i][j] = 0;
kol = n * m - 1;
step = 1;
mrk[x][y] = 1;
upd(ans[x][y], 1);
if (t == 1) {
int len = 0, tp = 0;
while (kol > 0){
tp = (tp + 1) % 4;
if (tp == 1) {
len += 2;
x--;
y++;
}
up(x, y, tp, len);
}
} else{
int len = 0, tp = 0;
while (kol > 0){
tp = (tp + 3) % 4;
if (tp == 3) {
len += 2;
x--;
y--;
}
up(x, y, tp, len);
}
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++)
cout << ans[i][j] << " ";
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
127 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |