#include #include #include #include #include using namespace std; int main() { string line, name, strX, strY; int numStops; int x, y, spacePos; vector uniqueNames; regex posInteger("[[:digit:]]+"); regex integer("(\\+|-)?[[:digit:]]+"); regex word("[A-Za-z0-9]+"); getline(cin, line); if (regex_match(line, posInteger)) numStops = atoi(line.c_str()); else { cout << "error first line not a positive integer\n"; exit(0); } if (numStops > 20) { cout << "number of stops is too large "; exit(0); } for (int i = 0; i < numStops; i++) { getline(cin, line); spacePos = line.find(' '); strX = line.substr(0, spacePos); line = line.substr(spacePos + 1); spacePos = line.find(' '); strY = line.substr(0, spacePos); name = line.substr(spacePos + 1); if (regex_match(strX, integer)) { x = atoi(strX.c_str()); if (x < -100 || x > 100) { cout << "error in poke row in line " << i << endl; exit(0); } } if (regex_match(strY, integer)) { y = atoi(strY.c_str()); if (y < -100 || y > 100) { cout << "error in poke column in line " << i << endl; exit(0); } } if (!regex_match(name, word)) { cout << "error in pokename in line " << i << endl; exit(0); } else if (find(uniqueNames.begin(), uniqueNames.end(), name) == uniqueNames.end()) uniqueNames.push_back(name); } if (uniqueNames.size() > 15) { cout << " too many pokemon\n"; exit(0); } return 42; }