fork download
  1. //If you are reading this then you are at wrong place.
  2. #include<bits/stdc++.h>
  3. #define mod 1000000007
  4. #define lli long long int
  5. using namespace std;
  6. int main()
  7. {
  8. // freopen("testcase.txt", "r", stdin);
  9. //freopen("output.txt", "w", stdout);
  10. ios_base::sync_with_stdio(0);
  11. cin.tie(0);
  12. cout.tie(0);
  13. lli t,i,j;
  14. t=1;
  15. lli counter1=0;
  16. while(t--)
  17. {
  18. counter1++;
  19. int n,m;
  20. cin>>n>>m;
  21. vector<int>answer;
  22. int print[n+1]={0};
  23. for(i=0;i<n;i++)
  24. answer.push_back(i);
  25. int l,r,x;
  26. while(m--)
  27. {
  28. cin>>l>>r>>x;
  29. l--;
  30. r--;
  31. x--;
  32. int q=lower_bound(answer.begin(),answer.end(),l)-answer.begin();
  33. while(q<answer.size())
  34. {
  35. if(answer[q]>r)
  36. break;
  37. if(answer[q]!=x)
  38. {
  39. print[answer[q]]=x;
  40. answer.erase(answer.begin()+q);
  41. q--;
  42. }
  43. q++;
  44. }
  45. }
  46. for(i=0;i<n;i++)
  47. {
  48. if(i!=x)
  49. cout<<print[i]+1<<" ";
  50. else
  51. cout<<print[i]<<" ";
  52. }
  53. cout<<endl;
  54.  
  55. //cout<<"Case #"<<counter1<<" ";
  56. //cout<<endl;
  57. }
  58. }
  59.  
Time limit exceeded #stdin #stdout 5s 15376KB
stdin
Standard input is empty
stdout
Standard output is empty