Submission #83505

# Submission time Handle Problem Language Result Execution time Memory
83505 2018-11-08T14:32:56 Z charlies_moo Spirale (COCI18_spirale) C++17
0 / 80
2 ms 588 KB
# 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 time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 372 KB Output isn't correct
3 Incorrect 2 ms 540 KB Output isn't correct
4 Incorrect 2 ms 540 KB Output isn't correct
5 Incorrect 2 ms 540 KB Output isn't correct
6 Incorrect 2 ms 540 KB Output isn't correct
7 Incorrect 2 ms 540 KB Output isn't correct
8 Incorrect 2 ms 588 KB Output isn't correct
9 Incorrect 2 ms 588 KB Output isn't correct
10 Incorrect 2 ms 588 KB Output isn't correct