Sgu 142
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;

int main() {
#ifdef ALEX
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#endif

  int k;
  int x1,y1,x2,y2;
  int x0,y0;
  vector< pair< pair<int,int>, pair<int,int> > > L;

  cin >> k;

  for (int i = 0; i < k ;i++)
  {
    cin >> x1 >> y1 >> x2 >> y2;
    if (y1 == y2) {
      if (x1 > x2) L.push_back(make_pair(make_pair(x2,y1), make_pair(x1,y2))); else L.push_back(make_pair(make_pair(x1,y1), make_pair(x2,y2)));
    } else {
      if (y1 > y2) L.push_back(make_pair(make_pair(x2,y2), make_pair(x1,y1))); else L.push_back(make_pair(make_pair(x1,y1), make_pair(x2,y2)));
    }

  }
  cin >> x0 >> y0;

  int c = 0;
  for (int i = 0; i < k; i++) {
    x1 = L[i].first.first;
    y1 = L[i].first.second;
    x2 = L[i].second.first;
    y2 = L[i].second.second;

    // on line
    if ((y1 == y2) && ((x1 <= x0) && (x2 >= x0)) && (y1 == y0)) {
      cout << "BORDER" << endl;
      return 0;
    }

    if ((x1 == x2) && ((y1 <= y0) && (y2 >= y0)) && (x1 == x0)) {
      cout << "BORDER" << endl;
      return 0;
    }

    // 1.
    if ((y1 == y2) && ((x1 <= x0) && (x2 > x0)) && (y1 > y0)) {
      c++;      
    }

    /*
    if ((x1 == x2) && (x1 == x0) && (y1 > y0)) {
      c++;
    }
    */

  }

  if (c%2) 
    cout << "INSIDE" << endl;
  else
    cout << "OUTSIDE" << endl;

  return 0;
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.