Submission #7570311
Source Code Expand
#include <iostream> // cout, cin, endl #include <string> // stoi #include <vector> // vector #include <algorithm> // max, min #include <iomanip> // setw, setfill #include <sstream> // ostringstream using namespace std; vector<int> round_to_five(int s, int e); bool shall_we_combine(vector<int> se1, vector<int> se2); int main() { // 入力受付 int N; cin >> N; string SE_in; vector<vector<int>> SE(N); int sn, en; for (int n = 0; n<N; n++) { cin >> SE_in; // ベクトル化 sn = stoi(SE_in.substr(0, SE_in.find_first_of("-"))); en = stoi(SE_in.substr(SE_in.find_first_of("-")+1, 4)); SE[n] = round_to_five(sn, en); } // 結合 vector<int> se1, se2; bool flg = true; while (flg) { flg = false; for (unsigned int i = 0; i < SE.size(); i++) { for (unsigned int j = 1; j < (SE.size() - i); j++) { se1 = SE[i]; se2 = SE[i+j]; if (shall_we_combine(se1, se2)) { SE.erase(SE.begin() + i+j); SE.erase(SE.begin() + i); vector<int> new_vec = { min(se1[0], se2[0]), max(se1[1], se2[1]) }; SE.push_back(new_vec); flg = true; goto LOOP_END; } } } LOOP_END:; } // 文字列化してソート vector<string> out; for (unsigned int i = 0; i < SE.size(); i++) { ostringstream ss; ss << setfill('0') << setw(4) << SE[i][0] << "-" << setfill('0') << setw(4) << SE[i][1]; out.push_back(ss.str()); } sort(out.begin(), out.end()); // 結果出力 for (unsigned int i = 0; i < out.size(); i++) { cout << out[i] << endl; } return 0; } vector<int> round_to_five(int s, int e) { // 5分単位にまるめてvectorを返す int s_fd; int e_fd; s_fd = s % 10; e_fd = e % 10; if (s_fd < 5) { s -= s_fd; } else { s = s - s_fd + 5; } if (e_fd != 0) { if (e_fd < 5) { e = e - e_fd + 5; } else { e = e - e_fd + 10; } } vector<int> ret = { s, e }; return ret; } bool shall_we_combine(vector<int> se1, vector<int> se2) { // startの大きいほうと、endの小さいほうを比較。かぶっていたら結合(true)を返す // int s_larger = max(se1[0], se2[0]); // int e_smaller = min(se1[1], se2[1]); if (max(se1[0], se2[0]) <= min(se1[1], se2[1])) { return true; } else { return false; } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | phorizon20 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2341 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 1920 KB |
Judge Result
Set Name | all | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 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 | TLE | 2096 ms | 1920 KB |
chokudai_ga_cho.txt | TLE | 2103 ms | 1920 KB |
test_01.txt | WA | 2 ms | 256 KB |
test_02.txt | WA | 2 ms | 256 KB |
test_03.txt | WA | 2 ms | 256 KB |
test_04.txt | WA | 2 ms | 256 KB |
test_05.txt | WA | 2 ms | 256 KB |
test_06.txt | AC | 2 ms | 256 KB |
test_07.txt | AC | 1 ms | 256 KB |
test_08.txt | AC | 1 ms | 256 KB |
test_09.txt | AC | 3 ms | 256 KB |
test_10.txt | AC | 3 ms | 256 KB |
test_11.txt | AC | 2 ms | 256 KB |
test_12.txt | AC | 2 ms | 256 KB |
test_13.txt | AC | 2 ms | 256 KB |
test_14.txt | AC | 2 ms | 256 KB |
test_15.txt | AC | 3 ms | 256 KB |
test_16.txt | AC | 3 ms | 256 KB |
test_17.txt | AC | 2 ms | 256 KB |
test_18.txt | AC | 2 ms | 256 KB |
test_19.txt | AC | 2 ms | 256 KB |
test_20.txt | AC | 2 ms | 256 KB |
test_21.txt | TLE | 2103 ms | 1920 KB |
test_22.txt | TLE | 2103 ms | 1920 KB |
test_23.txt | TLE | 2103 ms | 1920 KB |
test_24.txt | TLE | 2100 ms | 1920 KB |
test_25.txt | TLE | 2103 ms | 1920 KB |
test_26.txt | TLE | 2103 ms | 1920 KB |
test_27.txt | TLE | 2093 ms | 1920 KB |
test_28.txt | TLE | 2103 ms | 1920 KB |
test_29.txt | AC | 1 ms | 256 KB |
test_30.txt | WA | 2 ms | 256 KB |
test_31.txt | WA | 84 ms | 512 KB |
test_32.txt | WA | 1 ms | 256 KB |
test_33.txt | WA | 988 ms | 1280 KB |
test_34.txt | AC | 1 ms | 256 KB |
test_35.txt | WA | 2 ms | 256 KB |
test_36.txt | TLE | 2101 ms | 1920 KB |
test_37.txt | TLE | 2103 ms | 1920 KB |
test_38.txt | TLE | 2103 ms | 1920 KB |
test_39.txt | TLE | 2103 ms | 1920 KB |
test_40.txt | TLE | 2103 ms | 1920 KB |
test_41.txt | TLE | 2096 ms | 1920 KB |
test_42.txt | TLE | 2094 ms | 1920 KB |
test_43.txt | TLE | 2096 ms | 1920 KB |