Weather Observation Station 18

Sort by

recency

|

2515 Discussions

|

  • + 0 comments

    Oracle sample with cte for readability

    WITH ps AS ( 
        SELECT
            min(lat_n) P1a, 
            min(long_w) P1b, 
            max(lat_n) P2c, 
            max(long_w) P2d 
        FROM station)
    SELECT
        round((p2c -p1a) +(p2d-p1b),4) manhattan_distance
    FROM ps
    ;
    
  • + 0 comments
    • a = MIN(LAT_N)
    • b = MIN(LONG_W)
    • c = MAX(LAT_N)
    • d = MAX(LONG_W)
    • Manhattan Distance = (MAX(LAT_N) - MIN(LAT_N) + MAX(LONG_W) - MIN(LONG_W))

    SELECT round(MAX(LAT_N) - MIN(LAT_N) + MAX(LONG_W) - MIN(LONG_W) ,4) FROM STATION

  • + 0 comments
    • a = MIN(LAT_N)
    • b = MIN(LONG_W)
    • c = MAX(LAT_N)
    • d = MAX(LONG_W)
    • Manhattan Distance: |a-c| + |b-d|
    SELECT
        ROUND(ABS(MIN(LAT_N) - MAX(LAT_N))
              + ABS(MIN(LONG_W) - MAX(LONG_W)), 4)
    FROM STATION
    
  • + 0 comments

    select round( max(LONG_W)- min(LONG_W) + max(lat_n)- min(lat_n),4) from STATION;

  • + 0 comments

    SELECT CAST( ROUND(ABS(MAX(LAT_N)- MIN(LAT_N)) + ABS(MAX(lONG_W) - MIN(LONG_W)),4) AS DECIMAL(18,4) )AS manhattan FROM STATION;

    REASON:

    CAST(... AS DECIMAL(18,4)) → forces SQL to store and return the number as a fixed-point decimal with exactly 4 digits after the decimal point.

    DECIMAL(18,4) means: up to 18 total digits, 4 after the decimal.

    So the output is guaranteed to look like 259.6859 (not 259.685900000).

    Now the judge sees exactly the expected format → ✅ accepted.