[Offer收割]编程练习赛32 register

Ended

Participants:237

Verdict:Runtime Error
Score:60 / 100
Submitted:2017-10-22 14:09:52

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 50;
int x[maxn], y[maxn], d[maxn];
int g[maxn][maxn];
int n, k;
int main(){
    cin >> n >> k;
    for(int i = 0; i < k; i++){
        cin >> x[i] >> y[i] >> d[i];
        g[x[i]][y[i]] = max(g[x[i]][y[i]], d[i]);
    }
    for(int i = 0; i < k; i++){
        for(int j = 0; j < n; j++){
            for(int l = 0;l < n; l++){
                int dd = abs(x[i] - j) + abs(y[i] - l);
                g[j][l] = max(g[j][l], d[i] - dd);
                //cout << g[j][l]<<endl;
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX