cf 1187C Vasya And Array

Meaning of the questions:

  An array configuration, satisfy certain conditions:

  1.

    1 lr: lr within the range ai <= a (i + 1)

  2.

    There lr lr 0 within a range ai> a (i + 1)

Ideas:

  First of all incremental location mark, last seen each non-increasing range is not entirely in increments within the range, if there is a non-increasing range well within the range of increments is obviously impossible to construct, or can be constructed

  there is a question:

    Such incremental range are 1-2, 3-4, 2-3 is non-incremental, it will be well within the determination 2-3 1-4, 1-4 are actually two incremental range, in order to solve this question, we do not mark the first position increment range, that range increments are 2-2, 4-4, and 1-4 mark can distinguish between two increments range, check the non-increasing range, it also ignores the first check the position of

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <string>
 4 #include <queue>
 5 #include <cstring>
 6 #include <cmath>
 7 #include <algorithm>
 8 using namespace std;
 9 typedef long long LL;
10 typedef unsigned long long ULL;
11 typedef long double LD;
12 typedef pair<int, int> pii;
13 #define mem(a,x,n) memset(a,x,n)
14 #define FOR(i, a, b) for (int i = (a); i <= (b); i++)
15 #define pb push_back
16 #define f first
17 #define s second
18 #define lb lower_bound
19 #define ub upper_bound
20 LL gcd(LL a, LL b) { return b == 0 ? a : gcd(b, a%b);}
21 void fast_io() {ios_base::sync_with_stdio(0); cin.tie(0);}
22 const LD PI = 4*atan((LD)1);
23 const int INF = 0x3f3f3f3f;
24 ////////////////////////////////////////////////////////////
25 const int maxn = 1e5;
26 bool vis[1010];
27 int n, m, d[1005][2];
28 void init(){
29     cin>>n>>m;
30     memset(vis,0,1010);
31 }
32 
33 int main() {
34     the init ();
 35      int CNT = 0 ;
 36      the while (M-- ) {
 37 [          int T, L, R & lt;
 38 is          CIN >> T >> L >> R & lt;
 39          IF (T)
 40              Memset (VIS + L + . 1 , . 1 , rl is an); // tag range increment, a pay more attention front. 1 
41 is          the else 
42 is              D [CNT] [ 0 ] = L, D [CNT ++] [ . 1 ] = R & lt; // record nonincreasing range 
43 is      }
 44 is      the FOR (I, 0 , the CNT- . 1 ) //Check each non-increasing range is within the increment range of 
45      {    
 46 is          int In Flag = 0 ;
 47          for ( int J = D [I] [ 0 ] + . 1 ; J <= D [I] [ . 1 ]; J ++) // Note that front + 1, ignore the first position 
48          {
 49              IF (! VIS [J]) { // the point is not incremented if there is a range, let me when this configuration is less than a point before point 
50                  in Flag = . 1 ;
 51 is                  BREAK ;
 52 is              }
 53 is          }
 54 is          IF (! in Flag) // all points in the range of incremental output NO 
55         {
56             cout << "NO\n";
57             return 0;
58         }
59     }
60     cout << "YES\n";
61     int s = n+3;
62     FOR(i,1,n)
63     {
64         if(vis[i]) cout << s << (i==n?"":" ");//递增范围全部一样
65         else cout << --s <<(i==n?"":" "); // nonincrementing range, falling output 
66      }
 67      COUT << endl;
 68      return  0 ;
 69 }
View Code

 

Guess you like

Origin www.cnblogs.com/rookiezjz/p/11201381.html