fork download
  1. /**
  2. - author: orzvanh14 ( )
  3. - created: 23.12.2022 10:08:02
  4. - too lazy to update time
  5. **/
  6. // i wants to take ioi
  7. //binhtinhtutinkhongcaycunhungmotkhikhongcontutinnualatuyetvong
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define int long long
  13. #define nn "\n"
  14. #define pi pair<int, int>
  15. #define fi first
  16. #define se second
  17. #define lb lower_bound
  18. #define ub upper_bound
  19. #define eb emplace_back
  20. #define pb push_back
  21. #define TASK " "
  22.  
  23. #define ms(a, x) memset(a, x, sizeof(a))
  24. #define all(a) a.begin(), a.end()
  25. #define All(a, n) a + 1, a + 1 + n
  26.  
  27. #define LOG 21
  28.  
  29. typedef __int128 i128;
  30.  
  31. const int INF = 1e18;
  32. const int mod = 1e9 + 7;
  33. const int maxN = 5e6 + 5;
  34. const int N = 1e5 + 5;
  35. int MOD = 998244353;
  36. int bit[200000];
  37. struct node{
  38. int kc, u, v;
  39. bool operator<(const node& other) const {
  40. return kc > other.kc;
  41. }
  42. };
  43. struct edge{
  44. int u, v, w;
  45. bool operator<(const edge& other) const {
  46. return w < other.w;
  47. }
  48. };
  49. struct Node{
  50. int p, s;
  51. bool operator<(const Node& other) const {
  52. return s < other.s;
  53. }
  54. };
  55.  
  56. int n, q;
  57. int a[N], b[N];
  58.  
  59. void nhap(){
  60. cin >> n >> q;
  61. for(int i = 1; i <= n; i++) cin >> a[i];
  62. for(int i = 1; i <= n; i++) cin >> b[i];
  63. }
  64.  
  65. void solve(){
  66. while(q--){
  67. int type; cin >> type;
  68. if(type == 1){
  69. int l, r, k; cin >> l >> r >> k;
  70. for(int i = l; i <= r; i++) a[i] += k;
  71. }
  72. else if(type == 2){
  73. int l, r, k; cin >> l >> r >> k;
  74. for(int i = l; i <= r; i++) b[i] += k;
  75. }
  76. else if(type == 3){
  77. int l, r, k; cin >> l >> r >> k;
  78. for(int i = l; i <= r; i++) b[i] += a[i] * k;
  79. }
  80. else if(type == 4){
  81. int l, r, k; cin >> l >> r >> k;
  82. int mn = INF;
  83. for(int j = l; j <= r; j++) mn = min(mn, a[j]);
  84. for(int i = l; i <= r; i++){
  85. b[i] += k;
  86. a[i] = mn;
  87. }
  88. }
  89. else if(type == 5){
  90. int l, r; cin >> l >> r;
  91. int sum = 0;
  92. for(int i = l; i <= r; i++) sum = (sum + a[i] % mod) % mod;
  93. cout << (sum % mod + mod) % mod << nn;
  94. }
  95. else if(type == 6){
  96. int l, r; cin >> l >> r;
  97. int sum = 0;
  98. for(int i = l; i <= r; i++) sum = (sum + b[i] % mod) % mod;
  99. cout << (sum % mod + mod) % mod << nn;
  100. }
  101. }
  102. }
  103.  
  104. signed main() {
  105. // freopen("Bai4.inp", "r", stdin);
  106. // freopen("Bai4.out", "w", stdout);
  107. ios_base::sync_with_stdio(0);
  108. cin.tie(0);
  109. cout.tie(0);
  110. nhap();
  111. solve();
  112. return (0 ^ 0);
  113. }
Success #stdin #stdout 0s 2532KB
stdin
6 7
7 6 1 10 1 8
1 8 9 10 2 9
1 4 5 3
2 1 6 6
5 6 6
3 1 6 10
6 2 5
4 3 4 7
6 3 5
stdout
8
293
233