Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <fstream>
- #include <math.h>
- #include <vector>
- #include <bitset>
- #include <string>
- #include <stack>
- #include <queue>
- #include <map>
- #include <set>
- /*
- #pragma warning(disable:4244 4800)
- #include <gmp/mpirxx.h>
- // MPZ_CLASS
- // MPQ_CLASS
- // MPF_CLASS
- #pragma warning(default:4244 4800)
- */
- #define _CRT_SECURE_NO_DEPRECATE
- using namespace std;
- typedef long long ll;
- typedef vector<int> vi;
- typedef vector<vi> vi2;
- typedef pair<int, int> ii;
- typedef vector<ii> vii;
- #define FOR(i, a, b) \
- for (int i = int(a); i < int(b); i++)
- #define FORi(i, c) \
- for (auto i = (c).begin(); i != (c).end(); i++)
- string name = "mowing";
- ifstream in( name+".in" );
- ofstream out( name+".out" );
- // START
- int main()
- {
- // BEGIN
- int n, t;
- in >> n >> t;
- vi Xcoords( n );
- vi Ycoords( n );
- for( int i = 0; i < n; i++ )
- in >> Xcoords[i] >> Ycoords[i];
- int fh = (Ycoords[0] == Ycoords[1]) ? 1 : 0;
- int ANS = 0;
- for( int i = n-1; i > 0; i-- )
- {
- for( int j = i-t-1; j > 0; j-- )
- {
- if( i % 2 == fh ) // if horiz
- {
- int bigx = max( Xcoords[i], Xcoords[i-1] );
- int smallx = min( Xcoords[i], Xcoords[i-1] );
- int bigy = max( Ycoords[j], Ycoords[j-1] );
- int smally = min( Ycoords[j], Ycoords[j-1] );
- if( Ycoords[i] > smally && Ycoords[i] < bigy &&
- Xcoords[j] > smallx && Xcoords[j] < bigx )
- {
- ANS++;
- }
- } else // if vert
- {
- int bigy = max( Ycoords[i], Ycoords[i-1] );
- int smally = min( Ycoords[i], Ycoords[i-1] );
- int bigx = max( Xcoords[j], Xcoords[j-1] );
- int smallx = min( Xcoords[j], Xcoords[j-1] );
- if( Ycoords[j] > smally && Ycoords[j] < bigy &&
- Xcoords[i] > smallx && Xcoords[i] < bigx )
- {
- ANS++;
- }
- }
- }
- }
- out << ANS;
- // END
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement