QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#771453 | #9543. Good Partitions | yimg | WA | 236ms | 7876kb | C++20 | 1.9kb | 2024-11-22 13:09:34 | 2024-11-22 13:09:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 2e5 + 5;
int dnum[N];
void init(){
for(i64 i = 1; i <= N; ++i){
for(i64 j = 1; j * j <= i; ++j){
if(j * j == i) dnum[i]++;
else if(i % j == 0) dnum[i] += 2;
}
}
dnum[0] = 1;
}
struct Segment{
int n;
vector<int> tr;
Segment(int n_){
n = n_ + 1;
tr.resize(n * 4 + 50, 0);
}
void pull(int p){
tr[p] = __gcd(tr[p*2], tr[p*2 + 1]);
// cout << "PPP : " << tr[p * 2] << " " << tr[p * 2 + 1] << " " << tr[p] << "\n";
}
void update(int x, int v){
update(1, 1, n, x, v);
}
void update(int p, int l, int r, int x, int v){
// cout << p << ' ' << l << " " << r << "\n";
if(r - l == 1){
tr[p] = v;
return;
}
int m = l + r >> 1;
if(x < m) update(p*2, l, m, x, v);
else update(p*2 + 1, m, r, x, v);
pull(p);
}
int query(){
return tr[1];
}
};
void work()
{
int n, q;
cin >> n >> q;
vector<int> a(n + 1);
Segment seg(n);
for(int i = 1; i <= n; ++i){
cin >> a[i];
}
for(int i = 1; i < n; ++i){
if(a[i] > a[i + 1]) seg.update(i, i);
}
// cout << seg.query() << " ";
cout << dnum[seg.query()] << "\n";
while(q--){
int i, x;
cin >> i >> x;
a[i] = x;
if(i + 1 <= n && a[i] > a[i + 1]) seg.update(i, i);
else seg.update(i, 0);
if(i && a[i - 1] > a[i]) seg.update(i - 1, i - 1);
else seg.update(i - 1, 0);
// cout << seg.query() << " ";
cout << dnum[seg.query()] << "\n";
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
init();
while(t--)
work();
}
详细
Test #1:
score: 100
Accepted
time: 176ms
memory: 4336kb
input:
1 5 2 4 3 2 6 1 2 5 3 5
output:
1 2 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 180ms
memory: 4340kb
input:
1 1 1 2000000000 1 1999999999
output:
1 1
result:
ok 2 lines
Test #3:
score: -100
Wrong Answer
time: 236ms
memory: 7876kb
input:
1 200000 200000 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 160 1 ...
result:
wrong answer 2nd lines differ - expected: '200000', found: '1'