QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#301476 | #3679. 楼房重建 | duongnc000 | 100 ✓ | 117ms | 10964kb | C++23 | 2.3kb | 2024-01-09 22:44:12 | 2024-01-09 22:44:13 |
Judging History
answer
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;
const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;
struct SegmentTree {
int n;
vector<int> sm;
vector<long double> mx;
SegmentTree(int n) : n(n), sm(4 * n + 10), mx(4 * n + 10) {}
void update(int l, int r, int idx, int pos, long double val) {
if (l == r) {
mx[idx] = val;
sm[idx] = 1;
return;
}
int mid = (l + r) >> 1;
if (pos <= mid) update(l, mid, idx << 1, pos, val);
else update(mid + 1, r, idx << 1 | 1, pos, val);
mx[idx] = max(mx[idx << 1], mx[idx << 1 | 1]);
sm[idx] = sm[idx << 1] + calc(mid + 1, r, idx << 1 | 1, mx[idx << 1]);
}
void update(int pos, long double val) {
update(1, n, 1, pos, val);
}
int calc(int l, int r, int idx, long double val) {
if (mx[idx] < val) return 0;
if (l == r) return mx[idx] > val;
int mid = (l + r) >> 1;
if (mx[idx << 1] < val) return calc(mid + 1, r, idx << 1 | 1, val);
else return sm[idx] - sm[idx << 1] + calc(l, mid, idx << 1, val);
}
int getans() {
return sm[1];
}
};
int n, q;
void solve() {
cin >> n >> q;
SegmentTree st(n);
while (q--) {
int idx, val;
cin >> idx >> val;
st.update(idx, 1.0L * val / idx);
cout << st.getans() << endl;
}
}
signed main() {
#ifndef CDuongg
if(fopen(taskname".inp", "r"))
assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
freopen("bai3.inp", "r", stdin);
freopen("bai3.out", "w", stdout);
auto start = chrono::high_resolution_clock::now();
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; //cin >> t;
while(t--) solve();
#ifdef CDuongg
auto end = chrono::high_resolution_clock::now();
cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
cout << "Check array size pls sir" << endl;
#endif
}
详细
Test #1:
score: 10
Accepted
time: 1ms
memory: 3484kb
input:
10 100 6 166267291 4 764085103 1 12360641 1 846991393 6 383204345 2 69698641 9 12331341 1 772764651 5 131311041 10 46049537 6 690746401 2 145679903 10 758217 4 201987721 9 249525949 7 161049529 6 110578175 4 231517001 5 644489651 7 340648201 7 151799407 10 7480386 3 206257865 9 328935144 3 352739143...
output:
1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 100 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 3588kb
input:
5000 5000 4055 116561953 2381 100240024 2004 417074916 1427 997789281 3389 362989109 3151 584964927 1010 338776377 4005 652116037 679 787404691 1707 456436289 3237 116187877 763 591467095 4591 992346901 4771 675683041 3214 220111386 2959 491101999 1756 29122121 3931 269053489 1024 539141721 1298 362...
output:
1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 5000 lines
Test #3:
score: 10
Accepted
time: 48ms
memory: 6976kb
input:
50000 50000 11197 523959184 21870 174130291 8961 383622388 5855 17591001 2034 116080369 2999 48813129 13681 400639393 26120 545371291 10812 615573145 3846 224445841 23741 3512321 27980 425609076 20600 67673449 19022 21208449 7613 179168546 22248 582006973 3195 559122129 30805 882930960 2357 12836663...
output:
1 1 2 3 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 50000 lines
Test #4:
score: 10
Accepted
time: 79ms
memory: 10964kb
input:
100000 100000 20078 506888119 12662 18121087 9727 14838729 6119 4331773 4115 148763931 15246 155262241 16638 933023110 2671 278021329 7591 419392075 27852 148148071 9023 601987189 20034 325680001 15306 39381877 22314 907072316 22375 25876929 12920 1871849 12400 507255871 15242 403346861 13493 336991...
output:
1 2 2 3 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 100000 lines
Test #5:
score: 10
Accepted
time: 20ms
memory: 5360kb
input:
30000 30000 17319 15171443 25912 22698911 25733 22542107 18739 16415363 27670 24238919 15814 13853063 21762 19063511 28952 25361951 23861 20902235 23595 20669219 28799 25227923 24340 21321839 22710 19893959 22369 19595243 18955 16604579 29636 25961135 19807 17350931 26598 23299847 27967 24499091 195...
output:
1 2 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 100 101 102 ...
result:
ok 30000 lines
Test #6:
score: 10
Accepted
time: 31ms
memory: 6956kb
input:
50000 50000 49898 43710647 48279 42292403 27063 23707187 39809 34872683 40038 35073287 28476 24944975 45856 40169855 27643 24215267 31608 27688607 35509 31105883 49654 43496903 43563 38161187 49463 43329587 47666 41755415 42309 37062683 42435 37173059 44870 39306119 27322 23934071 42841 37528715 384...
output:
1 2 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 100 101 102 ...
result:
ok 50000 lines
Test #7:
score: 10
Accepted
time: 63ms
memory: 8584kb
input:
70000 70000 66320 65457839 69425 68522474 60370 59585189 65008 64162895 62987 62168168 45238 44649905 43693 43124990 69269 68368502 61265 60468554 44163 43588880 35096 34639751 54253 53547710 65657 64803458 66359 65496332 68429 67539422 45704 45109847 49336 48694631 37814 37322417 61266 60469541 530...
output:
1 2 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 100 101 102 ...
result:
ok 70000 lines
Test #8:
score: 10
Accepted
time: 68ms
memory: 9328kb
input:
80000 80000 75926 749845175 54296 536227295 70792 699141791 67587 667489211 68827 679735451 64067 632725691 76742 757903991 79231 782485355 77910 769439159 58999 582674123 66049 652299923 69783 689176907 70343 694707467 71891 709995515 70699 698223323 70767 698894891 66086 652665335 69294 684347543 ...
output:
1 2 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 100 101 102 ...
result:
ok 80000 lines
Test #9:
score: 10
Accepted
time: 117ms
memory: 10168kb
input:
90000 90000 57366 566546615 55176 544918175 62991 622099115 53284 526232783 78371 773991995 52628 519754127 89881 887664755 59895 591523019 51313 506767187 68146 673009895 74890 739613639 78727 777507851 66677 658502051 86236 851666735 70198 693275447 76456 755079455 45865 452962739 62514 617388263 ...
output:
1 2 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 100 101 102 ...
result:
ok 90000 lines
Test #10:
score: 10
Accepted
time: 48ms
memory: 10928kb
input:
100000 100000 82774 817476023 92562 914142311 55100 544167599 77673 767098547 84937 838837811 97569 963591443 87753 866648627 88967 878638091 85842 847775591 92889 917371763 53689 530232563 75333 743988707 82569 815451443 64934 641288183 63573 627846947 81009 800044883 98230 970119479 81765 80751113...
output:
1 2 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 100 101 102 ...
result:
ok 100000 lines