Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int int64_t
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n,q;
- cin>>n>>q;
- int r[n],c[n];
- for(int i=0;i<n;i++)
- {
- cin>>r[i];
- r[i]=r[i]%2;
- }
- for(int i=0;i<n;i++)
- {
- cin>>c[i];
- c[i]=c[i]%2;
- }
- vector<int> row(n),column(n);
- int k=0;
- row[0]=0;
- for(int i=1;i<n;i++)
- {
- if(r[i]==r[i-1])
- {
- row[i]=k;
- }
- else
- {
- k++;
- row[i]=k;
- }
- }
- k=0;
- for(int i=1;i<n;i++)
- {
- if(c[i-1]==c[i])
- {
- column[i]=k;
- }
- else
- {
- k++;
- column[i]=k;
- }
- }
- while(q--)
- {
- int xi,yi,xf,yf;
- cin>>xi>>yi>>xf>>yf;
- xi--;
- yi--;
- xf--;
- yf--;
- if((row[xi]==row[xf])&&(column[yi]==column[yf]))
- cout<<"YES"<<endl;
- else
- cout<<"NO"<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment