Submission #179745


Source Code Expand

import static java.util.Arrays.deepToString;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.DecimalFormat;
 
public class Main {
    private static final boolean isDebug = false;
    
    int N;
    
    static final String[] DIRECTION = {"N", "NNE", "NE", "ENE",
                                          "E", "ESE", "SE", "SSE",
                                          "S", "SSW", "SW", "WSW",
                                          "W", "WNW", "NW", "NNW",
    };
    
    static double[] WIND_POWER = {0.2, 1.5, 3.3, 5.4,
                                    7.9, 10.7, 13.8, 17.1,
                                    20.7, 24.4, 28.4, 32.6
    };
    
    
    boolean[][] isLain = new boolean[25][12];
    
    public final void solve4() throws Throwable { 
        
        int N = readBufInt();
        for (int i = 0; i < N; i++) {
            String[] line = br.readLine().split("-");
            int fromH = Integer.parseInt(line[0].substring(0,2));
            int fromM = Integer.parseInt(line[0].substring(2,4)) / 5;

            int toH = Integer.parseInt(line[1].substring(0,2));
            int toM = Integer.parseInt(line[1].substring(2,4));
            int tmp = 0;
            if (toM % 5 > 0) {
                tmp++;
            }
            toM = toM / 5 + tmp;
            
            d(fromH + " " + fromM);
            d(toH + " " + toM);
            
            
            boolean isFirstLine = true;
            for (; fromH <= toH; fromH++) {
                int loopFromM = 0;
                int loopToM = 12;
                
                if (isFirstLine) {
                    loopFromM = fromM;
                    isFirstLine = false;
                }
                if (fromH == toH) {
                    loopToM = toM;
                }
                
                for (;loopFromM < loopToM; loopFromM++) {
                    isLain[fromH][loopFromM] = true;
                }
                
            }
        }

        boolean isCall = false;
        int callH = 0;
        int callM = 0;
        DecimalFormat format = new DecimalFormat("00");
        for (int i = 0; i <= 24; i++) {
            for (int j = 0; j < 12; j++) {
                if (isCall) {
                    if (!isLain[i][j]) {
                        pw.println(format.format(callH) + 
                                   format.format(callM * 5) + 
                                   "-" +
                                   format.format(i) + 
                                   format.format(j * 5)
                                   );
                        isCall = false;
                    }
                } else {
                    if (isLain[i][j]) {
                        isCall = true;
                        callH = i;
                        callM = j;
                    }
                }
            }
        }
        
        
        
    }
    public final void solve2() throws Throwable { 
        startTime = System.currentTimeMillis();
        
        int m = readBufInt();
        
        int K = 1000;
 
        String V;
        
        if (m < 0.1 * K) {
            V = "00";
        } else if (m <= 5 * K) {
            int vInt = m * 10 / K ;
            if (vInt / 10 < 1) {
                V = "0" + vInt;
            } else {
                V = String.valueOf(vInt);
            }
        } else if (m <= 30 * K) {
            int vInt = m / K + 50;
            V = String.valueOf(vInt);
        } else if (m <= 70 * K) {
            int vInt = (m / K - 30) / 5 + 80;
            V = String.valueOf(vInt);
        } else {
            V = "89";
        }
        
        pw.println(V);
    }
    
    
    public final void solve3() throws Throwable { 
        startTime = System.currentTimeMillis();
        
        int dis = readBufInt();
        int deg = readBufInt();
        
        BigDecimal wPower = new BigDecimal(deg).divide(new BigDecimal(60), 1, BigDecimal.ROUND_HALF_UP);
        int wIndex = 12;
        for (int i = 0; i < 12; i++) {
            if (wPower.compareTo(new BigDecimal(WIND_POWER[i]).setScale(1, BigDecimal.ROUND_HALF_EVEN ))<= 0) {
                wIndex = i;
                break;
            }
        }

        String Dir = "C";;

        if (wIndex != 0) {
            int range = 36000 / 16;
            int start = range / 2;
            
            int dir = (dis * 10 + start) / range;
            if (dir > 15) dir = 0;
            Dir = DIRECTION[dir];
        }
        
        pw.println(Dir + " " + wIndex);
    }
    
    private static long gcd(long n1, long n2) {
        return (n2 == 0)?n1:gcd(n2, n1%n2);
    }

    private static int gcd(int n1, int n2) {
        return (n2 == 0)?n1:gcd(n2, n1%n2);
    }
    private int brPos = 0;
    private int[] brBuf = null;
    
    private final int readBufInt() throws IOException {
        if (brBuf == null || brBuf.length == brPos) {
            brBuf = readIntArray();
            brPos = 0;
        }
        return brBuf[brPos++];
    }

    private final int readInt() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    private final long readLong() throws IOException {
        return Long.parseLong(br.readLine());
    }

    private final int[] readIntArray() throws IOException {
        String[] s = readStrArray();
        int cnt = s.length;
        int[] out = new int[cnt];
        for (int i = 0; i < cnt; i++) out[i] = Integer.parseInt(s[i]);
        return out;
    }

    private final char[] readCharArray() throws IOException {
        String[] s = readStrArray();
        int cnt = s.length;
        char[] out = new char[cnt];
        for (int i = 0; i < cnt; i++) out[i] = s[i].charAt(0);
        return out;
    }

    private final long[] readLongArray() throws IOException {
        String[] s = readStrArray();
        int cnt = s.length;
        long[] out = new long[cnt];
        for (int i = 0; i < cnt; i++) out[i] = Long.parseLong(s[i]);
        return out;
    }

    private final String[] readStrArray() throws IOException {
        String[] s = br.readLine().split(" ");
        return s;
    }

    static long startTime;
    public static void main(String[] args) {
        Main app = new Main();
        try {
            app.br = new BufferedReader(new InputStreamReader(System.in));
            app.solve4();
        } catch(Throwable e) {
            e.printStackTrace();
        } finally {
            try { app.br.close();} catch (Exception igunore) {}
        }
        d(System.currentTimeMillis() - startTime + " ms");
        pw.flush();
        pw.close();
    }

   static final void d(Object ... o) {
       if (isDebug) pw.println(deepToString(o));
   }

   BufferedReader br = null;
   static PrintWriter pw = new PrintWriter(System.out);
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User tochukaso
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 7171 Byte
Status AC
Exec Time 757 ms
Memory 33164 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 432 ms 18852 KB
00_sample_02.txt AC 393 ms 18936 KB
00_sample_03.txt AC 388 ms 18812 KB
cho_cho_chokudai.txt AC 670 ms 31752 KB
chokudai_ga_cho.txt AC 701 ms 31348 KB
test_01.txt AC 400 ms 19528 KB
test_02.txt AC 403 ms 19396 KB
test_03.txt AC 394 ms 19268 KB
test_04.txt AC 399 ms 19272 KB
test_05.txt AC 399 ms 19408 KB
test_06.txt AC 435 ms 22112 KB
test_07.txt AC 417 ms 23192 KB
test_08.txt AC 425 ms 23304 KB
test_09.txt AC 430 ms 22524 KB
test_10.txt AC 421 ms 22512 KB
test_11.txt AC 426 ms 22500 KB
test_12.txt AC 431 ms 22384 KB
test_13.txt AC 399 ms 19280 KB
test_14.txt AC 415 ms 22300 KB
test_15.txt AC 423 ms 22764 KB
test_16.txt AC 393 ms 19056 KB
test_17.txt AC 423 ms 22476 KB
test_18.txt AC 388 ms 19872 KB
test_19.txt AC 417 ms 22840 KB
test_20.txt AC 403 ms 19656 KB
test_21.txt AC 667 ms 31552 KB
test_22.txt AC 694 ms 31228 KB
test_23.txt AC 724 ms 30916 KB
test_24.txt AC 716 ms 31652 KB
test_25.txt AC 654 ms 31156 KB
test_26.txt AC 673 ms 30064 KB
test_27.txt AC 757 ms 33164 KB
test_28.txt AC 687 ms 32984 KB
test_29.txt AC 429 ms 18900 KB
test_30.txt AC 394 ms 18928 KB
test_31.txt AC 540 ms 25924 KB
test_32.txt AC 394 ms 18924 KB
test_33.txt AC 677 ms 31708 KB
test_34.txt AC 381 ms 18864 KB
test_35.txt AC 431 ms 19408 KB
test_36.txt AC 706 ms 31264 KB
test_37.txt AC 718 ms 29996 KB
test_38.txt AC 753 ms 30932 KB
test_39.txt AC 716 ms 33052 KB
test_40.txt AC 702 ms 32964 KB
test_41.txt AC 662 ms 31496 KB
test_42.txt AC 694 ms 31256 KB
test_43.txt AC 703 ms 32276 KB