#pragma GCC optimize("unroll-loops")
#pragma gcc optimize("Ofast")
#pragma GCC optimization("Ofast")
#pragma optimize(Ofast)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define str string
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define print(a) for(auto x : a) cout << x << ' '; cout << endl;
void __print(signed x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const str &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const array<int, 2> &x)
{
cerr << '{';
__print(x[0]);
cerr << ',';
__print(x[1]);
cerr << '}';
}
template <typename T, typename V>
void __print(const pair<T, V> &x)
{
cerr << '{';
__print(x.fs);
cerr << ',';
__print(x.ss);
cerr << '}';
}
template <typename T>
void __print(const T &x)
{
int f = 0;
cerr << '{';
for (auto &y : x)
cerr << (f++ ? "," : ""), __print(y);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
__print(t);
if (sizeof...(v))
cerr << ", ";
_print(v...);
}
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#ifdef ONLINE_JUDGE
#define debug(x...) 42
#endif
const int mod = 1e9 + 7;
struct SegTree
{
int size = 1;
vector<int> tree;
SegTree(int n)
{
while (n > size)
size <<= 1;
tree.resize(size << 1);
}
void update(int l, int r, int v, int x, int lx, int rx){
if(l <= lx and rx <= r){
tree[x] += v;
return;
}
if(rx <= l or rx <= lx)
return;
int m = (lx + rx) >> 1;
update(l, r, v, (x << 1) + 1, lx, m);
update(l, r, v, (x << 1) + 2, m, rx);
}
void update(int l, int r, int v){
return update(l, r, v, 0, 0, size);
}
int query(int l, int r, int x, int lx, int rx){
if(l <= lx and rx <= r)
return tree[x];
if(rx <= l or r <= lx)
return 0;
int mid = (lx + rx) >> 1;
return query(l, r, (x << 1) + 1, lx, mid) + query(l, r, (x << 1) + 2, mid, rx);
}
inline int query(int l, int r){
return query(l, r, 0, 0, size);
}
};
void solve(){
int n, m, q;
cin >> n >> m >> q;
if(m == 1){
SegTree s(n);
for(int i = 0; i < q; i ++){
int t;
cin >> t;
if(t == 1){
int l, r, c, k;
cin >> l >> r >> c >> k;
l --;
s.update(l, r, k);
}
else if(t == 2){
int l, r, c, k;
cin >> l >> r >> c >> k;
l --;
s.update(l, r, k);
}
else{
int l, r;
cin >> l >> r;
cout << s.query(l - 1, r) << endl;
}
}
}
}
signed main()
{
fastio;
int t = 1;
// cin >> t;
while (t--)
{
solve();
cout << endl;
}
}
Compilation message
foodcourt.cpp:2: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
2 | #pragma gcc optimize("Ofast")
|
foodcourt.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization("Ofast")
|
foodcourt.cpp:4: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
4 | #pragma optimize(Ofast)
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
8796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |