Submission #83505

#TimeUsernameProblemLanguageResultExecution timeMemory
83505charlies_mooSpirale (COCI18_spirale)C++17
0 / 80
2 ms588 KiB
# include <iostream> # include <fstream> using namespace std; int main(){ ifstream fin ("lighting.in"); ofstream fout ("lighting.out"); int n, m, k, inf, x, y, t, i, j, p; fin >> n >> m >> k; inf = n * m * 10; int arr[n][m]; for(i=0;i<n;i++){ for(j=0;j<m;j++){ arr[i][j] = inf; } } for(p=1;p<=k;p++){ int num, counter, length, direction; num = 1; length = 1; direction = -1; fin >> x >> y >> t; x -= 1; y -= 1; if(t==0){ t=1; } else{ t=-1; } arr[x][y] = num; counter = 1; while(counter < (n * m)){ for(i=1;i<=length;i++){ num += 1; x += direction; if(x<0||x>=n||y<0||y>=m){ continue; } if(arr[x][y] > num){ arr[x][y] = num; } counter += 1; } direction = 0 - direction; for(i=1;i<=length;i++){ num += 1; y += direction * t; if(x<0||x>=n||y<0||y>=m){ continue; } if(arr[x][y] > num){ arr[x][y] = num; } counter += 1; } length += 1; } } for(i=0;i<n;i++){ for(j=0;j<m;j++){ fout << arr[i][j] << " "; } fout << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...