Submission #3373403

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main(){
    int i, j, k;
    int N, x[100], y[100], h[100];
    cin >> N;
    for(i=0; i<N; i++) cin >> x[i] >> y[i] >> h[i];

    for(int Cx=0; Cx<=100; Cx++){
        for(int Cy=0; Cy<=100; Cy++){
            int H = -1; // -1:未確定
            int Hmax = 2e9; // h[i]=0である点から要求されるHの上限
            bool success = true;
            for(i=0; i<N; i++){
                int d = abs(Cx-x[i]) + abs(Cy-y[i]);
                if(h[i] > 0){
                    int H2 = h[i] + d;
                    if(H > 0 && H != H2){
                        success = false;
                        break;
                    }else{
                        H = H2;
                    }
                }else{
                    Hmax = min(Hmax, d);
                }
            }
            if(success && H <= Hmax){
                cout << Cx << " " << Cy << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

Submission Info

Submission Time
Task C - Pyramid
User betrue12
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1054 Byte
Status
Exec Time 3 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 300 / 300 in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
in01.txt 1 ms 256 KB
in02.txt 1 ms 256 KB
in03.txt 1 ms 256 KB
in04.txt 1 ms 256 KB
in05.txt 1 ms 256 KB
in06.txt 1 ms 256 KB
in07.txt 1 ms 256 KB
in08.txt 1 ms 256 KB
in09.txt 1 ms 256 KB
in10.txt 1 ms 256 KB
in11.txt 1 ms 256 KB
in12.txt 1 ms 256 KB
in13.txt 1 ms 256 KB
in14.txt 1 ms 256 KB
in15.txt 1 ms 256 KB
in16.txt 1 ms 256 KB
in17.txt 1 ms 256 KB
in18.txt 1 ms 256 KB
in19.txt 1 ms 256 KB
in20.txt 3 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB