QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204066 | #4940. Token Distance | triplem5ds# | WA | 8ms | 12428kb | C++23 | 3.0kb | 2023-10-07 00:42:36 | 2023-10-07 00:42:36 |
Judging History
answer
/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll
using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 1e5 + 5, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-7;
int n, q;
int sum[N << 2];
int mn[N << 2];
int mx[N << 2];
int a[N];
void pull(int node) {
sum[node] = sum[node << 1] + sum[node << 1 | 1];
mx[node] = max(mx[node << 1], mx[node << 1 | 1]);
mn[node] = min(mn[node << 1], mn[node << 1 | 1]);
}
void build(int node, int s, int e) {
if (s == e) {
sum[node] = a[s];
mn[node] = a[s];
mx[node] = a[s];
return;
}
int md = (s + e) >> 1;
build(node << 1, s, md);
build(node << 1 | 1, md + 1, e);
pull(node);
}
void update(int node, int s, int e, int index, int val) {
if (s == e) {
sum[node] = val;
mn[node] = val;
mx[node] = val;
return;
}
int md = (s + e) >> 1;
if (index <= md)
update(node << 1, s, md, index, val);
else
update(node << 1 | 1, md + 1, e, index, val);
pull(node);
}
array<int, 3> query(int node, int s, int e, int l, int r) {
if (r < s || e < l)return {0, 1000000001, 0};
if (l <= s && e <= r)return {sum[node], mn[node], mx[node]};
int md = (s + e) >> 1;
auto a = query(node << 1, s, md, l, r);
auto b = query(node << 1 | 1, md + 1, e, l, r);
return {
a[0] + b[0],
min(a[1], b[1]),
max(a[2], b[2])
};
}
void doWork() {
cin >> n >> q;
f(i, 1, n + 1) cin >> a[i];
build(1, 1, n);
while (q--) {
int tp, x, y;
cin >> tp >> x >> y;
if (tp == 1) {
update(1, 1, n, x, y);
} else {
if ((y - x + 1) < 3) {
cout << "YES\n";
} else {
auto val = query(1, 1, n, x, y);
int diff = val[2] - val[1];
if (diff % (y - x)) {
cout << "NO\n";
} else {
diff /= (y - x);
if (val[1] * (y - x + 1) + diff * (y - x) * (y - x + 1) / 2 == val[0])
cout << "YES\n";
else
cout << "NO\n";
}
}
}
}
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--) {
doWork();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7712kb
input:
5 7 1 1 1 10 1 2 1 3 2 1 5 1 5 4 1 3 7 2 2 4 2 2 5 2 4 5
output:
YES NO NO YES YES
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 9580kb
input:
2 1 0 1000000000 2 1 2
output:
YES
result:
ok single line: 'YES'
Test #3:
score: -100
Wrong Answer
time: 8ms
memory: 12428kb
input:
81473 13549 972586683 972586964 972587245 972587526 972587807 972588088 972588369 972588650 972588931 972589212 972589493 972589774 972590055 972590336 972590617 972590898 972591179 972591460 972591741 972592022 972592303 972592584 972592865 972593146 972593427 972593708 972593989 972594270 97259455...
output:
YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES NO YES NO YES YES YES YES YES NO YES NO YES NO YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES NO YES YES YES NO YES YES Y...
result:
wrong answer 5th lines differ - expected: 'NO', found: 'YES'