Submission #2176342
Source Code Expand
#include <string> #include <stdio.h> #include <math.h> int main(){ //5分刻みのタイムラインのどのcellが占有されているかを記録するbool配列 //要素数は24*60/5 = 288 //初期値は全てfalse bool cell[288+1]; for (int i = 0;i < 288+1;i++){ cell[i] = false; } //Nの入力 int N; scanf("%d",&N); //S,Eの入力と同時に、タイムラインの雨が降っているcellをtrueにする for (int i = 0;i < N;i++){ //S,Eの入力 char SE[10]; scanf("%s",SE); //char SE配列から時刻を復元する //S,Eそれぞれを直前・直後の5分単位の時刻に丸める char tmp1[3] = {SE[0],SE[1],'\0'}; char tmp2[3] = {SE[2],SE[3],'\0'}; char tmp3[3] = {SE[5],SE[6],'\0'}; char tmp4[3] = {SE[7],SE[8],'\0'}; int S_h = std::stoi(tmp1); int S_m = std::stoi(tmp2)-std::stoi(tmp2)%5; int E_h = std::stoi(tmp3); int E_m; if (std::stoi(tmp4)%5 == 0){ E_m = std::stoi(tmp4); }else{ E_m = std::stoi(tmp4)-std::stoi(tmp4)%5+5; } //上記の4つの変数からcellのindexを算出 //該当するcellをtrueにする int S_i = 12*S_h+S_m/5; int E_i = 12*E_h+E_m/5; for (int j = S_i;j < E_i;j++){ cell[j] = true; } } //cellをスキャン int start = -1; for (int i = 0;i < 288+1;i++){ if (start == -1 && cell[i] == true){ start = i; } if (start != -1 && cell[i] == false){ //区間の終端の決定 int end = i; //start,endから、時刻を復元 int S_h = (start-start%12)/12; int S_m = start%12*5; int E_h = (end-end%12)/12; int E_m = end%12*5; //区間の出力 std::string out; if (S_h < 10){ out += "0"+std::to_string(S_h); }else{ out += std::to_string(S_h); } if (S_m < 10){ out += "0"+std::to_string(S_m); }else{ out += std::to_string(S_m); } out += "-"; if (E_h < 10){ out += "0"+std::to_string(E_h); }else{ out += std::to_string(E_h); } if (E_m < 10){ out += "0"+std::to_string(E_m); }else{ out += std::to_string(E_m); } printf("%s\n",out.c_str()); //区間の初端のリセット start = -1; } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | melpoyo |
Language | C++ (Clang 3.8.0) |
Score | 100 |
Code Size | 2821 Byte |
Status | AC |
Exec Time | 14 ms |
Memory | 256 KB |
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
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 | 1 ms | 256 KB |
00_sample_02.txt | AC | 1 ms | 256 KB |
00_sample_03.txt | AC | 1 ms | 256 KB |
cho_cho_chokudai.txt | AC | 13 ms | 256 KB |
chokudai_ga_cho.txt | AC | 13 ms | 256 KB |
test_01.txt | AC | 1 ms | 256 KB |
test_02.txt | AC | 1 ms | 256 KB |
test_03.txt | AC | 1 ms | 256 KB |
test_04.txt | AC | 1 ms | 256 KB |
test_05.txt | AC | 1 ms | 256 KB |
test_06.txt | AC | 1 ms | 256 KB |
test_07.txt | AC | 1 ms | 256 KB |
test_08.txt | AC | 1 ms | 256 KB |
test_09.txt | AC | 1 ms | 256 KB |
test_10.txt | AC | 1 ms | 256 KB |
test_11.txt | AC | 1 ms | 256 KB |
test_12.txt | AC | 1 ms | 256 KB |
test_13.txt | AC | 1 ms | 256 KB |
test_14.txt | AC | 1 ms | 256 KB |
test_15.txt | AC | 1 ms | 256 KB |
test_16.txt | AC | 1 ms | 256 KB |
test_17.txt | AC | 1 ms | 256 KB |
test_18.txt | AC | 1 ms | 256 KB |
test_19.txt | AC | 1 ms | 256 KB |
test_20.txt | AC | 1 ms | 256 KB |
test_21.txt | AC | 14 ms | 256 KB |
test_22.txt | AC | 13 ms | 256 KB |
test_23.txt | AC | 13 ms | 256 KB |
test_24.txt | AC | 14 ms | 256 KB |
test_25.txt | AC | 13 ms | 256 KB |
test_26.txt | AC | 13 ms | 256 KB |
test_27.txt | AC | 13 ms | 256 KB |
test_28.txt | AC | 14 ms | 256 KB |
test_29.txt | AC | 1 ms | 256 KB |
test_30.txt | AC | 1 ms | 256 KB |
test_31.txt | AC | 3 ms | 256 KB |
test_32.txt | AC | 1 ms | 256 KB |
test_33.txt | AC | 9 ms | 256 KB |
test_34.txt | AC | 1 ms | 256 KB |
test_35.txt | AC | 1 ms | 256 KB |
test_36.txt | AC | 13 ms | 256 KB |
test_37.txt | AC | 13 ms | 256 KB |
test_38.txt | AC | 13 ms | 256 KB |
test_39.txt | AC | 13 ms | 256 KB |
test_40.txt | AC | 13 ms | 256 KB |
test_41.txt | AC | 11 ms | 256 KB |
test_42.txt | AC | 12 ms | 256 KB |
test_43.txt | AC | 11 ms | 256 KB |