QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#569737 | #9104. Zayin and Forest | SGColin# | WA | 28ms | 19244kb | C++17 | 1.3kb | 2024-09-17 09:56:00 | 2024-09-17 09:56:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll rd() {
ll x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
inline ll lowbit(ll x) {return x & -x;}
const int N = 10000007;
ll c[N];
inline void add(int pos, ll val) {
for (; pos < N; pos += lowbit(pos)) c[pos] += val;
}
inline ll sum(int pos) {
ll ret = 0;
for (; pos; pos -= lowbit(pos)) ret += c[pos];
return ret;
}
inline ll sum(int L, int R) {
return sum(R) - sum(L - 1);
}
int main() {
vector<ll> s;
vector<tuple<int, ll, ll>> q;
ll n = rd(), m = rd();
rep(i, 1, m) {
int op = rd();
ll l = rd(), r = rd();
q.eb(op, l, r);
if (op == 1) while (l <= n) {s.eb(l); l += lowbit(l);}
}
sort(all(s));
s.erase(unique(all(s)), s.end());
auto getv = [&](ll w) {
return lower_bound(all(s), w) - s.begin() + 1;
};
for (auto [op, L, R] : q) {
if (op == 1) {
while (L <= n) {
add(getv(L), R);
L += lowbit(L);
}
} else printf("%lld\n", sum(getv(L), getv(R)));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 28ms
memory: 19244kb
input:
1000000000 20000 2 384578735 526547442 1 64211261 592970906 1 512065247 448267721 1 44993150 127180320 1 880319036 927623947 1 170536687 572121854 1 896600029 804033011 1 666246328 754201635 1 654066651 179982083 2 240989825 984888006 2 372004567 858916479 2 76127818 98606736 1 181794163 902842353 1...
output:
0 43148875202 17613404710 0 32808578044 28190043566 15641637055 78276219892 14955165236 20262224725 105057452192 17002492367 57916137452 27165464255 72766353838 39458327919 38294102627 264448717384 0 70928519548 279674530483 88885017175 111813205414 69703816663 211506104092 104120007714 34403738515 ...
result:
wrong answer 23rd lines differ - expected: '111664599432', found: '111813205414'