Alex_tz307

School-CCC Track the cars - Level 1

Oct 28th, 2020 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("text.in");
  6. ofstream fout("text.out");
  7.  
  8. struct rectangle {
  9.     string x1, y2, x2, y1;
  10. };
  11.  
  12. int main() {
  13.     /* int N;
  14.     fin >> N; */
  15.     vector < rectangle > a(1);
  16.     for(auto& x : a) {
  17.         string s;
  18.         fin >> s;
  19.         int p = 0;
  20.         while(isdigit(s[p]) || s[p] == '.')
  21.             x.x2.push_back(s[p++]);
  22.         ++p;
  23.         while(isdigit(s[p]) || s[p] == '.')
  24.             x.y2.push_back(s[p++]);
  25.         ++p;
  26.         while(isdigit(s[p]) || s[p] == '.')
  27.             x.x1.push_back(s[p++]);
  28.         ++p;
  29.         while(isdigit(s[p]) || s[p] == '.')
  30.             x.y1.push_back(s[p++]);
  31.     }
  32.     int T;
  33.     fin >> T;
  34.     int ans = 0;
  35.     while(T--) {
  36.         string s, lin, col;
  37.         fin >> s;
  38.         int p = 0;
  39.         while(isdigit(s[p]) || s[p] == '.')
  40.             lin.push_back(s[p++]);
  41.         ++p;
  42.         while(isdigit(s[p]) || s[p] == '.')
  43.             col.push_back(s[p++]);
  44.         bool ok = false;
  45.         for(auto x : a)
  46.             if(lin >= x.x1 && lin <= x.x2 && col >= x.y1 && col <= x.y2)
  47.                 ok = true;
  48.         if(ok)
  49.             ++ans;
  50.     }
  51.     fout << ans;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment