Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <algorithm>
- #include <fstream>
- #include <cmath>
- #include <cstdlib>
- #include <iomanip>
- #include <map>
- #include <set>
- #define eps 0.1
- using namespace std;
- long long prod(long long x){
- long long t=0;
- long long res=1;
- while(true){
- res*=x%10;
- x/=10;
- if (x==0)
- break;
- }
- return res;
- }
- bool pairComp(pair<long long, long long> pair1, pair<long long, long long> pair2){
- return ((pair1.first<=pair2.first && pair1.second>=pair2.second)?true:false);
- }
- int main()
- {
- //ifstream fin("file.in");
- //ofstream fout("file.out");
- long long n, m;
- long long max=0;
- long long ress=0;
- long long maxi=0;
- long long mass;
- long long mas[800200]={};
- map < long long, pair< long long, long long>> mapp;
- cin.sync_with_stdio(false);
- cin >> n >> m;
- cout.sync_with_stdio(false);
- for ( long long i=0; i<n; i++){
- cin >> mas[i];
- }
- for ( long long i=0; i<m; i++){
- pair< long long, long long> pairr;
- cin >> pairr.first >> pairr.second;
- mapp[i]=pairr;
- }
- /*for ( long long i=1; i<n; i++){
- if (mas[i]>mas[i-1])
- mas1[i]=1;
- else
- mas1[i]=0;*/
- //cout << mas1[i];
- map<pair<long long, long long>, bool> sett;
- //cin.tie(0);
- bool b;
- bool dd;
- pair<long long, long long> pairrr;
- for ( long long i=0; i<m; i++){
- b=true;
- dd = false;
- //cout << mapp[i].first << ' ' << mapp[i].second << endl;
- pairrr = mapp[i];
- for (auto &h:sett){
- if (!((h.first.first==h.first.second)||pairrr.first==pairrr.second)){
- if (pairComp(h.first,pairrr)&&(h.second)){
- b=true;
- dd=true;
- }
- if (pairComp(pairrr,h.first)&&(!h.second)){
- b=false;
- dd=true;
- }
- }
- }
- if (pairrr.first == pairrr.second){
- b=false;
- //dd=true;
- }
- if (- mas[pairrr.first-1] + mas[pairrr.second-1] - pairrr.second + pairrr.first < 0){
- //cout << - mas[mapp[i].first-1] + mas[mapp[i].second-1] - mapp[i].second + mapp[i].first << endl;
- b=false;
- dd=true;
- }
- if (!dd){
- for ( long long j=pairrr.first; j<pairrr.second; j++){
- //cout << mas[j] << ' ' << mas[j+1] << ' ' << mas[mapp[i].second-j+mapp[i].first-2] << ' ' << mas[mapp[i].second-j+mapp[i].first-1] << endl;
- //cout << (mas[j]<=mas[j-1]) << ' ' << (mas[mapp[i].second-j+mapp[i].first-1]>=mas[mapp[i].second-j+mapp[i].first]) << endl;
- if ((mas[j]<=mas[j-1]) || (mas[pairrr.second-j+pairrr.first-2]>=mas[pairrr.second-j+pairrr.first-1])){
- //cout << mas1[j] << " : " << j << endl;
- //cout << mas[j] << " : " << mas[j-1] << endl;
- b=false;
- }
- }
- }
- //sett[mapp[i]] = b;
- cout << (b?"Y":"N");
- }
- cout << endl;
- //cout << ress << endl;
- //fin.close();
- //fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement