code
unknown
plain_text
a year ago
832 B
6
Indexable
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n,q;
cin>>n>>q;
vector<int> vec(n,1);
vector<set<int>> vc(n);
while(q--) {
int l,r,k;
cin>>l>>r>>k;
l--;
r--;
for(int i=l;i<=r;i++) {
vc[i].insert(k);
while(vec[i]<=n && vc[i].count(vec[i])==1) {
vec[i]++;
}
}
bool smt = true;
for(int i=l;i<=r;i++) {
if(vec[i]<=n) {
smt = false;
break;
}
}
if(smt) {
cout<<-1<<endl;
return;
}
}
for(int i=0;i<n;i++) {
cout<<vec[i]<<" ";
}
cout<<endl;
}
int32_t main() {
// your code goes here
int T;
cin>>T;
while(T--) {
solve();
}
}
Editor is loading...
Leave a Comment