Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <deque>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <list>
- #include <map>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <vector>
- #define fst first
- #define snd second
- #define all(x) (x).begin(), (x).end()
- #define clr(a, v) memset( a , v , sizeof(a) )
- #define pb push_back
- #define mp make_pair
- #define sz size()
- #define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
- #define FOR( i , n ) FORN( i , 0 , n )
- #define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
- #define trace(x) cerr << #x << ": " << x << endl;
- #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
- #define read ios::sync_with_stdio(false)
- using namespace std;
- typedef long long int64;
- typedef vector <int> vi;
- typedef pair <int,int> ii;
- typedef vector <string> vs;
- typedef vector <ii> vii;
- struct seg{
- int ini, type, fin, cnt, ind;
- bool operator < (seg V) const{
- if ( ini !=V.ini ) return ini <V.ini ;
- if ( type!=V.type ) return type<V.type;
- return fin<V.fin;
- }
- } V[2*100002] ;
- struct act{
- int fin;
- int ind;
- int cnt;
- bool operator < (act V) const{
- if ( fin !=V.fin ) return fin <V.fin ;
- return ind<V.ind;
- }
- };
- int main(){
- int N,M;
- scanf("%d",&N);
- seg aux;
- FOR(i,N){
- scanf("%d %d",&aux.ini,&aux.fin);
- aux.ind=i+1;
- aux.type=2;
- V[i]=aux;
- }
- scanf("%d",&M);
- FOR(i,M){
- scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
- aux.ind=i+1;
- aux.type=1;
- V[N+i]=aux;
- }
- sort(V,V+(N+M));
- set < act > S;
- set < act >::iterator it;
- act p;
- int ans[N];
- int use[M];
- FOR(i,M) use[i]=0;
- bool flag=1;
- FOR(i,N+M){
- if ( V[i].type==1 ){
- p.fin=V[i].fin;
- p.ind=V[i].ind;
- p.cnt=V[i].cnt;
- S.insert(p);
- }
- else{
- p.fin=V[i].fin;
- p.ind=-1;
- it=lower_bound(all(S),p);
- if ( it==S.end() ) {flag=0; break;}
- p=*it;
- ans[V[i].ind-1]=p.ind;
- use[p.ind-1]++;
- if ( use[p.ind-1]==p.cnt ) S.erase(it);
- }
- }
- if (flag) {
- printf("YES\n")
- FOR(i,N) printf("%d ",ans[i]);
- }
- else printf("NO\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement