結果
問題 | No.138 化石のバージョン |
ユーザー |
|
提出日時 | 2016-03-14 12:15:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 780 bytes |
コンパイル時間 | 639 ms |
コンパイル使用メモリ | 56,648 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 13:52:33 |
合計ジャッジ時間 | 1,880 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <string> #include <iostream> struct Version { int major, minor, patch; }; bool operator<(const Version &fossil, const Version &v) { if (fossil.major != v.major) { return fossil.major < v.major; } else if (fossil.minor != v.minor) { return fossil.minor < v.minor; } else { return fossil.patch < v.patch; } } Version to_ver(std::string v) { auto idx = v.find('.'); auto major = v.substr(0, idx); v = v.substr(idx + 1); idx = v.find('.'); auto minor = v.substr(0, idx); auto patch = v.substr(idx + 1); return Version{ std::stoi(major), std::stoi(minor), std::stoi(patch) }; } int main() { std::string fossil, ver; std::cin >> fossil >> ver; if (to_ver(fossil) < to_ver(ver)) { std::cout << "NO\n"; } else { std::cout << "YES\n"; } return 0; }