fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pii pair<ll,ll>
  5. const ll N=1000005;
  6. const ll inf=1e18;
  7. ll n,q;
  8. ll diff[N];
  9. int main()
  10. {
  11. //freopen(".inp","r",stdin);
  12. //freopen(".out","w",stdout);
  13. ios_base::sync_with_stdio(0);
  14. cin.tie(0);cout.tie(0);
  15. cin>>n>>q;
  16. while(q--)
  17. {
  18. ll l,r;
  19. cin>>l>>r;
  20. diff[l]++;
  21. diff[r+1]--;
  22. }
  23. ll light=0;
  24. for(ll i=1;i<=n;i++)
  25. {
  26. light+=diff[i];
  27. cout<<(light&1)<<' ';
  28. }
  29. }
  30.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty