Submission #6641749
Source Code Expand
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
namespace io {
// Input
using IS = istream;
IS &in(IS &i) { return i; }
template <class T, class... Ts> IS &in(IS &i, T &a, Ts &... as) {
return in(i >> a, as...);
}
template <class V> IS &operator>>(IS &i, vector<V> &a) {
for_each(a.begin(), a.end(), [&i](auto &e) { i >> e; });
return i;
}
template <class F, class S> IS &operator>>(IS &i, pair<F, S> const &p) {
return in(p.first, p.second);
}
template <class... Ts, size_t... I>
IS &tuple_in(IS &i, tuple<Ts...> &t, index_sequence<I...>) {
return in(i, get<I>(t)...);
}
template <class... Ts> IS &operator>>(IS &i, tuple<Ts...> &t) {
return tuple_in(i, t, make_index_sequence<sizeof...(Ts)>());
}
// Output
using OS = ostream;
OS &out(OS &o) { return o << endl; }
template <class T> OS &out(OS &o, T const &a) { return o << a << endl; }
template <class T, class... Ts> OS &out(OS &o, T const &a, Ts const &... as) {
return out(o << a << " ", as...);
}
template <class F, class S> OS &operator<<(OS &o, pair<F, S> const &p) {
return o << "(" << p.first << " : " << p.second << ")";
}
template <class... Ts> OS &args_out(OS &o, Ts const &... ts);
OS &args_out(OS &o) { return o; }
template <class T> OS &args_out(OS &o, T const &t) { return o << t; }
template <class T0, class T1, class... Ts>
OS &args_out(OS &o, T0 const &t0, T1 const &t1, Ts const &... ts) {
return args_out(o << t0 << ",", t1, ts...);
}
template <class... Ts, size_t... I>
OS &tuple_out(OS &o, tuple<Ts...> const &t, index_sequence<I...>) {
return args_out(o, get<I>(t)...);
}
template <class... Ts> OS &operator<<(OS &o, tuple<Ts...> const &t) {
return tuple_out(o << "(", t, make_index_sequence<sizeof...(Ts)>()) << ")";
}
template <
class C,
class T = typename iterator_traits<typename C::iterator>::value_type,
typename enable_if<!is_same<C, string>::value, nullptr_t>::type = nullptr>
OS &operator<<(OS &o, C const &a) {
return a.empty() ? (o << "[]") : ([&o, &a]() -> OS & {
o << "[" << *a.begin();
for_each(next(a.begin()), a.end(), [&o](auto const &e) { o << "," << e; });
return o << "]";
}());
}
} // namespace io
template <class... Xs> void input(Xs &... xs) { io::in(cin, xs...); }
template <class... Xs> void print(Xs const &... xs) { io::out(cout, xs...); }
#ifdef JUMPAKU_DEBUG
template <class... Xs> void dump(Xs const &... xs) { io::out(cout, xs...); }
#else
template <class... Xs> void dump(Xs const &... xs) {}
#endif
// Hash
namespace hashcode {
template <class... Ts> size_t hash_args(size_t h, Ts const &... ts);
size_t hash_args(size_t h) { return h; }
template <class T, class... Ts>
size_t hash_args(size_t h, T const &t, Ts const &... ts) {
return hash_args(h * 31 + hash<T>{}(t), ts...);
}
template <class... Ts, size_t... I>
size_t hash_tuple(tuple<Ts...> const &t, index_sequence<I...>) {
return hash_args(17, get<I>(t)...);
}
} // namespace hashcode
namespace std {
template <class... Ts> struct hash<tuple<Ts...>> {
size_t operator()(tuple<Ts...> const &t) const {
return hashcode::hash_tuple(t, index_sequence_for<Ts...>());
}
};
template <class T> struct hash<unordered_set<T>> {
size_t operator()(unordered_set<T> const &s) const {
return accumulate(s.begin(), s.end(), 0, [](auto const &a, auto const &e) {
return a + hash<T>{}(e);
});
}
};
} // namespace std
// Types
using ll = long long int;
template <class T> using u_set = unordered_set<T>;
template <class K, class V> using u_map = unordered_map<K, V>;
// Range
vector<ll> range(ll const &begin, ll const &end) {
vector<ll> ret(max(0LL, end - begin));
iota(ret.begin(), ret.end(), begin);
return ret;
}
vector<ll> range(ll const &end) { return range(0, end); }
template <class T = ll> vector<T> vec(size_t n, T &&init = T()) {
return vector<T>(n, init);
}
template <class Itr, class T = typename iterator_traits<Itr>::value_type>
vector<T> vec(Itr begin, Itr end) {
return vector<T>(begin, end);
}
// MOD
ll gcd(ll p, ll q) { return (q == 0) ? p : gcd(q, p % q); }
ll pow(ll a, ll n, ll m) {
if (n == 0)
return 1;
if (n & 1)
return ((a % m) * pow(a, n - 1, m)) % m;
auto b = pow(a, n / 2, m);
return (b * b) % m;
}
ll inv(ll a, ll p) { return pow(a, p - 2, p); }
constexpr ll MOD = 1e9 + 7;
#include <chrono>
using namespace chrono;
using TP = system_clock::time_point;
using namespace io;
namespace io {
OS &operator<<(OS &o, TP const &t) {
auto tmp = system_clock::to_time_t(t);
return o << put_time(gmtime(&tmp), "%H%M");
}
} // namespace io
int main() {
ll N;
input(N);
auto SE = vec<string>(N);
input(SE);
auto time = map<TP, ll>{};
for (auto &se : SE) {
ll sm = stoll(se.substr(2, 2));
sm -= sm % 5;
ll sh = stoll(se.substr(0, 2));
time[TP(hours(sh) + minutes(sm))] += 1;
ll em = stoll(se.substr(7, 2));
em += (em % 5 == 0) ? 0 : (5 - (em % 5));
ll eh = stoll(se.substr(5, 2)) + (em == 60 ? 1 : 0);
em %= 60;
time[TP(hours(eh) + minutes(em))] -= 1;
}
auto rains = 0LL;
for (auto const &t : time) {
if (rains == 0 && t.second > 0)
cout << t.first << "-";
rains += t.second;
if (rains == 0 && t.second < 0) {
if (t.first == TP(hours(24LL)))
cout << "2400" << endl;
else
cout << t.first << endl;
}
}
}
Submission Info
Submission Time |
|
Task |
D - 感雨時刻の整理 |
User |
Jumpaku |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
5751 Byte |
Status |
AC |
Exec Time |
35 ms |
Memory |
2432 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 |
32 ms |
2304 KB |
chokudai_ga_cho.txt |
AC |
33 ms |
2432 KB |
test_01.txt |
AC |
2 ms |
256 KB |
test_02.txt |
AC |
2 ms |
256 KB |
test_03.txt |
AC |
2 ms |
256 KB |
test_04.txt |
AC |
2 ms |
256 KB |
test_05.txt |
AC |
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 |
2 ms |
256 KB |
test_10.txt |
AC |
2 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 |
2 ms |
256 KB |
test_16.txt |
AC |
1 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 |
AC |
34 ms |
2432 KB |
test_22.txt |
AC |
35 ms |
2432 KB |
test_23.txt |
AC |
34 ms |
2432 KB |
test_24.txt |
AC |
34 ms |
2432 KB |
test_25.txt |
AC |
34 ms |
2432 KB |
test_26.txt |
AC |
35 ms |
2432 KB |
test_27.txt |
AC |
32 ms |
2304 KB |
test_28.txt |
AC |
34 ms |
2428 KB |
test_29.txt |
AC |
1 ms |
256 KB |
test_30.txt |
AC |
1 ms |
256 KB |
test_31.txt |
AC |
6 ms |
636 KB |
test_32.txt |
AC |
1 ms |
256 KB |
test_33.txt |
AC |
23 ms |
1664 KB |
test_34.txt |
AC |
1 ms |
256 KB |
test_35.txt |
AC |
2 ms |
256 KB |
test_36.txt |
AC |
34 ms |
2428 KB |
test_37.txt |
AC |
34 ms |
2428 KB |
test_38.txt |
AC |
34 ms |
2432 KB |
test_39.txt |
AC |
34 ms |
2304 KB |
test_40.txt |
AC |
34 ms |
2428 KB |
test_41.txt |
AC |
33 ms |
2432 KB |
test_42.txt |
AC |
34 ms |
2432 KB |
test_43.txt |
AC |
33 ms |
2432 KB |