Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Memory: 2.87 MB
- // Time: 0.225 s
- #include <iostream>
- #include <vector>
- #include <string>
- #include <sstream>
- #include <algorithm>
- int main()
- {
- using namespace std;
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- vector<int> vFrom;
- vector<int> vTo;
- string line;
- istringstream iss;
- while (getline(cin, line) && line != ".")
- {
- int from, to;
- iss.clear();
- iss.str(line);
- iss >> from >> to;
- vFrom.push_back(from);
- vTo.push_back(to);
- }
- int first = vFrom[0], last = vTo[vTo.size() - 1];
- ostringstream os;
- while (getline(cin, line) && line != ".")
- {
- int n;
- iss.clear();
- iss.str(line);
- iss >> n;
- if (n < first || n > last)
- os << "out\n";
- else
- {
- auto it = lower_bound(vTo.begin(), vTo.end(), n);
- int index = it - vTo.begin();
- if (n >= vFrom[index] && n <= vTo[index])
- os << "in\n";
- else
- os << "out\n";
- }
- }
- cout << os.str();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement