#include <iostream>
#include <cassert>
#include <vector>
#include <string>
using namespace std;
bool validate_extension_downgrade_error_message(std::vector<std::string> &args) {
if(args.size() != 2) {
return false;
}
int from[2] = {0, 0};
int to[2] = {0, 0};
auto parser = [](std::string version, int result[2]) {
auto dot_pos = version.find('.');
if (dot_pos == std::string::npos) {
result[0] = std::stoi(version);
} else {
result[0] = std::stoi(version.substr(0, dot_pos));
assert(dot_pos < version.length() - 1);
result[1] = std::stoi(version.substr(dot_pos + 1));
}
if (result[0] < 0 || result[1] < 0) {
throw std::invalid_argument("Version cant be negative");
}
};
try {
parser(args[0], from);
parser(args[1], to);
} catch (const std::invalid_argument &e) {
return false;
}
// cout << from[0] << " " << from[1] << " " << " vs " << to[0] << " " << to[1] << endl;
return !std::lexicographical_compare(from, from + 2, to, to + 2);;
}
int main() {
std::vector<std::string> input;
input = {"1.100", "1.96"};
cout << validate_extension_downgrade_error_message(input) << endl;
input = {"2", "1.96"};
cout << validate_extension_downgrade_error_message(input) << endl;
input = {"1.0", "1.96"};
cout << validate_extension_downgrade_error_message(input) << endl;
input = {"1.00", "-1.96"};
cout << validate_extension_downgrade_error_message(input) << endl;
input = {"1.0", "1.96", "2"};
cout << validate_extension_downgrade_error_message(input) << endl;
input = {"afsgaw", "idjwubqqdds"};
cout << validate_extension_downgrade_error_message(input) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y2Fzc2VydD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgdmFsaWRhdGVfZXh0ZW5zaW9uX2Rvd25ncmFkZV9lcnJvcl9tZXNzYWdlKHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiAmYXJncykgewogICAgaWYoYXJncy5zaXplKCkgIT0gMikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGludCBmcm9tWzJdID0gezAsIDB9OwogICAg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