結果
| 問題 |
No.525 二度寝の季節
|
| コンテスト | |
| ユーザー |
not_522
|
| 提出日時 | 2018-11-22 00:45:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 3,828 bytes |
| コンパイル時間 | 1,157 ms |
| コンパイル使用メモリ | 122,068 KB |
| 最終ジャッジ日時 | 2025-01-06 17:07:24 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 33 |
ソースコード
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>
using namespace std;
struct BoolName : numpunct<char> {
string t, f;
BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
string do_truename() const {return t;}
string do_falsename() const {return f;}
};
struct Initializer {
Initializer() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15) << boolalpha;
cout.imbue(locale(cout.getloc(), new BoolName));
}
} initializer;
template<typename T> istream& operator>>(istream &s, vector<T> &v) {
for (T &t : v) s >> t;
return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
for (const T &t : v) s << t << endl;
return s;
}
void set_bool_name(string t, string f) {
cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}
template<typename T> class Addition {
public:
template<typename V> T operator+(const V& v) const {
return T(static_cast<const T&>(*this)) += v;
}
};
template<typename T> class Subtraction {
public:
template<typename V> T operator-(const V& v) const {
return T(static_cast<const T&>(*this)) -= v;
}
};
template<typename T> class Multiplication {
public:
template<typename V> T operator*(const V& v) const {
return T(static_cast<const T&>(*this)) *= v;
}
};
template<typename T> class Division {
public:
template<typename V> T operator/(const V& v) const {
return T(static_cast<const T&>(*this)) /= v;
}
};
template<typename T> class Modulus {
public:
template<typename V> T operator%(const V& v) const {
return T(static_cast<const T&>(*this)) %= v;
}
};
template<typename T> class IndivisibleArithmetic : public Addition<T>, public Subtraction<T>, public Multiplication<T> {};
template<typename T> class Arithmetic : public IndivisibleArithmetic<T>, public Division<T> {};
struct Time : public Addition<Time>, public Subtraction<Time> {
int hour, minute, second;
Time() : hour(0), minute(0), second(0) {}
Time(int hour, int minute, int second) : hour(hour), minute(minute), second(second) {normalize();}
int toMinutes() const {
return hour * 60 + minute;
}
int toSeconds() {
return toMinutes() * 60 + second;
}
void normalize() {
while (second < 0) {
--minute;
second += 60;
}
while (second >= 60) {
++minute;
second -= 60;
}
while (minute < 0) {
--hour;
minute += 60;
}
while (minute >= 60) {
++hour;
minute -= 60;
}
while (hour < 0) hour += 24;
while (hour >= 24) hour -= 24;
}
Time operator+=(const Time& time) {
hour += time.hour;
minute += time.minute;
second += time.second;
normalize();
return *this;
}
Time operator-=(const Time& time) {
hour -= time.hour;
minute -= time.minute;
second -= time.second;
normalize();
return *this;
}
};
template<typename T = int64_t> T toInteger(const string&);
template<> int toInteger<int>(const string& s) {
return stoi(s);
}
template<> int64_t toInteger<int64_t>(const string& s) {
return stoll(s);
}
template<typename T = int64_t> T toInteger(const string& s, int n) {
T res = 0;
for (char c : s) {
if (isdigit(c)) res = res * n + c - '0';
else if (isalpha(c)) res = res * n + tolower(c) - 'a' + 10;
}
return s[0] == '-' ? -res : res;
}
int main() {
string t;
cin >> t;
int h = toInteger(t.substr(0, 2));
int m = toInteger(t.substr(3, 2));
Time time(h, m, 0);
time += Time(0, 5, 0);
cout << setw(2) << setfill('0') << time.hour << ":" << setw(2) << setfill('0') << time.minute << endl;
}
not_522