fork(1) download
  1. #include <cstring>
  2. #include <vector>
  3. #include <list>
  4. #include <map>
  5. #include <set>
  6. #include <deque>
  7. #include <stack>
  8. #include <bitset>
  9. #include <algorithm>
  10. #include <functional>
  11. #include <numeric>
  12. #include <utility>
  13. #include <sstream>
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <cstdlib>
  19. #include <ctime>
  20. #include <memory.h>
  21. #include <cassert>
  22.  
  23. using namespace std;
  24.  
  25. const int N = 200010;
  26.  
  27. int from[N], to[N], num[N];
  28. int s[N][30];
  29. int a[N][30];
  30. int sum[N][30];
  31.  
  32. int main() {
  33. int n, m;
  34. scanf("%d %d", &n, &m);
  35. for (int i = 0; i <= n; i++) {
  36. for (int j = 0; j < 30; j++) {
  37. s[i][j] = 0;
  38. }
  39. }
  40. for (int k = 0; k < m; k++) {
  41. scanf("%d %d %d", from + k, to + k, num + k);
  42. from[k]--; to[k]--;
  43. for (int j = 0; j < 30; j++) {
  44. if (num[k] & (1 << j)) {
  45. s[from[k]][j]++;
  46. s[to[k] + 1][j]--;
  47. }
  48. }
  49. }
  50. for (int j = 0; j < 30; j++) {
  51. int bal = 0;
  52. sum[0][j] = 0;
  53. for (int i = 0; i < n; i++) {
  54. bal += s[i][j];
  55. a[i][j] = (bal > 0);
  56. sum[i + 1][j] = sum[i][j] + a[i][j];
  57. }
  58. }
  59. for (int k = 0; k < m; k++) {
  60. for (int j = 0; j < 30; j++) {
  61. if (!(num[k] & (1 << j))) {
  62. int get = sum[to[k] + 1][j] - sum[from[k]][j];
  63. int need = (to[k] + 1) - (from[k]);
  64. if (get == need) {
  65. puts("NO");
  66. return 0;
  67. }
  68. }
  69. }
  70. }
  71. puts("YES");
  72. for (int i = 0; i < n; i++) {
  73. int res = 0;
  74. for (int j = 0; j < 30; j++) {
  75. if (a[i][j]) {
  76. res += (1 << j);
  77. }
  78. }
  79. if (i > 0) printf(" ");
  80. printf("%d", res);
  81. }
  82. printf("\n");
  83. return 0;
  84. }
Success #stdin #stdout 0s 76032KB
stdin
Standard input is empty
stdout
YES