Advertisement
Alexandre_lsv

Untitled

Mar 6th, 2016
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <algorithm>
  4. #include <fstream>
  5. #include <cmath>
  6. #include <cstdlib>
  7. #include <iomanip>
  8. #include <map>
  9. #include <set>
  10. #define eps 0.1
  11. using namespace std;
  12. long long prod(long long x){
  13.     long long t=0;
  14.     long long res=1;
  15.     while(true){
  16.         res*=x%10;
  17.         x/=10;
  18.         if (x==0)
  19.             break;
  20.     }
  21.     return res;
  22. }
  23. bool pairComp(pair<long long, long long> pair1, pair<long long, long long> pair2){
  24.     return ((pair1.first<=pair2.first && pair1.second>=pair2.second)?true:false);
  25. }
  26. int main()
  27. {
  28.     //ifstream fin("file.in");
  29.     //ofstream fout("file.out");
  30.     long long n, m;
  31.     long long max=0;
  32.     long long ress=0;
  33.     long long maxi=0;
  34.     long long mass;    
  35.     long long mas[800200]={};
  36.     map < long long, pair< long long,  long long>> mapp;
  37.     cin.sync_with_stdio(false);
  38.     cin >> n >> m;
  39.     cout.sync_with_stdio(false);
  40.     for ( long long i=0; i<n; i++){
  41.         cin >> mas[i];
  42.     }
  43.     for ( long long i=0; i<m; i++){
  44.         pair< long long, long long> pairr;
  45.         cin >> pairr.first >> pairr.second;
  46.         mapp[i]=pairr;
  47.     }
  48.     /*for ( long long i=1; i<n; i++){
  49.         if (mas[i]>mas[i-1])
  50.             mas1[i]=1;
  51.         else
  52.             mas1[i]=0;*/
  53.         //cout << mas1[i];
  54.     map<pair<long long, long long>, bool> sett;
  55.     //cin.tie(0);
  56.     bool b;
  57.     bool dd;
  58.     pair<long long, long long> pairrr;
  59.     for ( long long i=0; i<m; i++){
  60.         b=true;
  61.         dd = false;
  62.         //cout << mapp[i].first << ' ' << mapp[i].second << endl;
  63.         pairrr = mapp[i];
  64.         for (auto &h:sett){
  65.             if (!((h.first.first==h.first.second)||pairrr.first==pairrr.second)){
  66.                 if (pairComp(h.first,pairrr)&&(h.second)){
  67.                     b=true;
  68.                     dd=true;
  69.                 }
  70.                 if (pairComp(pairrr,h.first)&&(!h.second)){
  71.                     b=false;
  72.                     dd=true;
  73.                 }
  74.             }
  75.         }
  76.         if (pairrr.first == pairrr.second){
  77.             b=false;
  78.             //dd=true;
  79.         }
  80.         if (- mas[pairrr.first-1] + mas[pairrr.second-1] - pairrr.second + pairrr.first < 0){
  81.             //cout << - mas[mapp[i].first-1] + mas[mapp[i].second-1] - mapp[i].second + mapp[i].first << endl;
  82.             b=false;
  83.             dd=true;
  84.         }  
  85.         if (!dd){
  86.             for ( long long j=pairrr.first; j<pairrr.second; j++){
  87.                 //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;
  88.                 //cout << (mas[j]<=mas[j-1]) << ' '  << (mas[mapp[i].second-j+mapp[i].first-1]>=mas[mapp[i].second-j+mapp[i].first]) << endl;
  89.                 if ((mas[j]<=mas[j-1]) || (mas[pairrr.second-j+pairrr.first-2]>=mas[pairrr.second-j+pairrr.first-1])){
  90.                     //cout << mas1[j] << " : "  << j << endl;
  91.                     //cout << mas[j] << " : " << mas[j-1] << endl;
  92.                     b=false;
  93.                 }
  94.             }
  95.         }
  96.         //sett[mapp[i]] = b;
  97.         cout << (b?"Y":"N");
  98.     }
  99.     cout << endl;
  100.     //cout << ress << endl;
  101.     //fin.close();
  102.     //fout.close();
  103.     return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement