QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#536751 | #4563. Radio Towers | Wansur# | 4 | 56ms | 15464kb | C++23 | 2.1kb | 2024-08-29 16:18:51 | 2024-08-29 16:18:51 |
Judging History
answer
#include "towers.h"
#include <bits/stdc++.h>
#define ent '\n'
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 12;
int dp[maxn], a[maxn];
int p[20][maxn], lg[maxn];
int n, d;
struct segtree{
int t[maxn * 4];
segtree(){
for(int i=0;i<maxn*4;i++){
t[i] = 0;
}
}
void upd(int v, int tl, int tr, int pos, int x){
if(tl == tr){
t[v] = x;
}
else{
int mid = tl + tr >> 1;
if(pos <= mid){
upd(v*2, tl, mid, pos, x);
}
else{
upd(v*2+1, mid+1, tr, pos, x);
}
t[v] = max(t[v*2], t[v*2+1]);
}
}
int get(int v, int tl, int tr, int l, int r){
if(tl > r || l > tr) return 0;
if(tl >= l && tr <= r) return t[v];
int mid = tl + tr >> 1;
return max(get(v*2, tl, mid, l, r), get(v*2+1, mid+1, tr, l, r));
}
} ft, st;
int get(int l, int r){
if(l > r) return 0;
int k = lg[r - l + 1];
return max(p[k][l], p[k][r - (1 << k) + 1]);
}
void init(int N, std::vector<int> H) {
n = N;
for(int i=1;i<=n;i++){
a[i] = p[0][i] = H[i - 1];
if(i > 1) lg[i] = lg[i / 2] + 1;
}
for(int k=1;k<20;k++){
for(int i=1;i + (1 << k) - 1 <= n;i++){
p[k][i] = max(p[k-1][i], p[k-1][i + (1 << (k - 1))]);
}
}
}
int max_towers(int l, int r, int D) {
d = D;
l++, r++;
if(get(l+1, r-1) - d >= max(a[l], a[r])) return 2;
return 1;
vector<int> ord;
for(int i=l;i<=r;i++){
ord.push_back(i);
}
sort(ord.begin(), ord.end(), [](int i, int j){
return a[i] < a[j];
});
set<int> s;
for(int i:ord){
auto it = s.upper_bound(i);
bool ok = 1;
ok &= (it == s.end() || get(i + 1, *it - 1) - d >= a[i]);
if(s.size() && it != s.begin()){
it--;
ok &= (get(*it+1, i-1) - d >= a[i]);
}
if(ok) s.insert(i);
}
return s.size();
}
詳細信息
Subtask #1:
score: 4
Accepted
Test #1:
score: 4
Accepted
time: 21ms
memory: 15464kb
input:
59640 49885 57346 58504 87383 113182 129676 204090 205404 259925 276583 300332 324014 333675 359377 364049 408489 414852 428310 438038 440113 458193 554789 643468 666525 683112 690791 707313 720088 741028 748785 789826 796576 800966 832867 851750 861044 862283 900756 926925 939560 955678 965636 9740...
output:
1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 47004 lines
Test #2:
score: 4
Accepted
time: 37ms
memory: 15256kb
input:
100000 2578 13067 19114 20399 28997 31651 32660 44354 74124 80988 88107 95439 96029 102645 103539 132139 137628 158023 174859 192033 205256 217839 227259 243992 248025 260099 283750 285030 294864 297371 303073 333910 343091 343725 359151 361656 361691 386777 414415 419149 425074 433963 447813 448681...
output:
1 1 1 1 1 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 2 1 1 1 1 1 1 1 1 1 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 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 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 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 100002 lines
Test #3:
score: 4
Accepted
time: 56ms
memory: 14640kb
input:
100000 13114 25925 27245 67202 68073 76184 110151 123581 140992 143871 146221 155748 165589 167167 168714 171437 172941 193840 194941 197306 200400 218140 230901 232201 246351 256019 260798 270505 295025 297243 308012 322193 346038 355192 366304 396540 414362 422681 428999 432243 434231 444296 47452...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 1 1 1 1 1 1 1 1 1 1 1 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 1 1 1 1 1 1 1 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 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 ...
result:
ok 100002 lines
Test #4:
score: 4
Accepted
time: 40ms
memory: 14728kb
input:
100000 5700 16956 35944 39194 51761 52173 81805 105452 109633 118593 123359 137554 140598 144792 159902 205292 216922 221444 228388 264645 275797 312855 317157 317211 346139 386655 414208 420637 428337 428731 441479 462812 473900 512659 530585 531009 539066 541910 546178 587753 622729 662273 672038 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 100002 lines
Test #5:
score: 4
Accepted
time: 37ms
memory: 14736kb
input:
100000 999988197 999986623 999976776 999962270 999951065 999947015 999903896 999903807 999891790 999885112 999877561 999867525 999861234 999819451 999804835 999800656 999792796 999785754 999774226 999765965 999763733 999757041 999755039 999754683 999735689 999725096 999723596 999697826 999692425 999...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 100002 lines
Test #6:
score: 4
Accepted
time: 47ms
memory: 14992kb
input:
100000 6846 27030 27974 37358 50621 62404 65145 70521 83772 99764 103069 115739 118757 122093 131124 161358 163926 192258 220922 221834 229360 240485 256289 274164 288418 297330 299248 304572 312235 330527 340606 343538 347549 349819 381756 399043 400603 401181 403223 405524 426129 429182 440198 440...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 100002 lines
Test #7:
score: 4
Accepted
time: 44ms
memory: 14556kb
input:
100000 999993000 999985279 999974372 999973105 999972338 999935099 999930231 999929661 999915510 999914373 999909600 999909476 999902789 999890841 999821968 999815754 999785501 999754085 999740116 999733261 999721841 999718823 999718208 999711968 999704389 999695063 999684278 999682448 999663281 999...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 100002 lines
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 10804kb
input:
425 753881706 405729786 890889563 29736246 598281970 208352067 357783003 663497023 178397034 4832890 562140755 510307001 354540290 538848551 436879256 86659033 42928516 24145404 749159097 118423198 506851985 204895765 719719998 726244368 991372008 681703480 799303017 657138050 88278945 417801236 260...
output:
1
result:
wrong answer 3rd lines differ - expected: '13', found: '1'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #65:
score: 0
Wrong Answer
time: 43ms
memory: 14456kb
input:
99308 491693640 24020487 317364185 726230755 737284540 951143270 709116045 641023337 360629062 964879440 47884022 532494780 803629825 635450854 688041998 573937055 113198481 191311841 929603572 636688 598629732 895342035 396521271 619919754 716589045 657789547 373121546 866402108 609316614 60046511 ...
output:
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 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 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 ...
result:
wrong answer 3rd lines differ - expected: '11903', found: '2'
Subtask #5:
score: 0
Wrong Answer
Test #86:
score: 0
Wrong Answer
time: 14ms
memory: 14748kb
input:
23881 605288257 422163932 155875880 339929874 76049859 196344969 958160745 767945284 469191956 997116006 387749577 15911341 920437918 367576975 800789357 351557615 283723284 369507452 841548133 643412903 309731505 256549694 370065644 699518122 559017597 347646657 469353381 575240521 501893001 454519...
output:
2 2 1 2 2 2 1 2 1 2 2 2 1 1 2 2 2 2 2 1 2 2 2 1 1 1 2 1 2 2 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 2 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 1 1 2 1 2 2 2 2 2 2 1 1 2 1 1 2 2 1 1 1 2 2 2 2 1 1 2 1 1 2 1 2 2 2 2 1 1 ...
result:
wrong answer 3rd lines differ - expected: '7197', found: '2'
Subtask #6:
score: 0
Skipped
Dependency #4:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%