QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250868 | #6390. Inspections | Luzhuoyuan | 22 | 193ms | 30016kb | C++14 | 1.7kb | 2023-11-13 20:03:19 | 2023-11-13 20:03:19 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define pr pair<int,int>
#define mkp make_pair
#define pb push_back
#define It set<node>::iterator
using namespace std;
const int N=2e5+5;
int n,m,q;
vector<pr> ve;
inline int read(){
int x=0;
char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x;
}
map<int,int> mp;
struct node{
int l,r;
mutable int v;
const bool operator<(node x)const{return l<x.l;}
};
set<node> s;
inline It spl(int p){
It it=s.lower_bound({p,0,0});
if(it!=s.end()&&it->l==p)return it;
it--;
int l=it->l,r=it->r,v=it->v;
s.erase(it);
s.insert({l,p-1,v});
return s.insert({p,r,v+p-l}).first;
}
inline void emg(int l,int r,int v){
It ir=spl(r+1),il=spl(l);
for(It it=il;it!=ir;it++)
if(it->v>0)mp[v+(it->l)-l-(it->v)]+=(it->r)-(it->l)+1;
s.erase(il,ir);s.insert({l,r,v});
}
inline int find(int x){
if(x<ve[0].first)return ve[ve.size()-1].second;
int l=0,r=ve.size()-1;
while(l<=r){
int mid=(l+r)>>1;
if(ve[mid].first<=x)l=mid+1;
else r=mid-1;
}
return ve[ve.size()-1].second-ve[r].second;
}
signed main(){
n=read(),m=read(),q=read();
s.insert({1,n,(int)-1e9});
for(int i=1,num=1;i<=m;i++){
int l=read(),r=read();
emg(l,r,num);num+=r-l+1;
}
for(auto i=mp.begin();i!=mp.end();i++)ve.pb(*i);
//for(pr v:ve)printf("%lld %lld\n",v.first,v.second);
for(int i=1;i<(int)ve.size();i++)
ve[i].second+=ve[i-1].second;
while(q--){
int x=read();
printf("%lld ",find(x));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 11
Accepted
time: 0ms
memory: 3812kb
input:
20 20 10 3 16 8 17 17 18 6 16 7 7 3 19 8 13 4 15 5 7 1 18 17 18 3 13 1 10 6 10 2 8 11 18 1 14 9 18 3 16 4 15 8 2 17 19 12 15 7 17 4 3
output:
150 165 64 40 122 79 150 64 165 165
result:
ok single line: '150 165 64 40 122 79 150 64 165 165 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
200 200 200 30 198 22 155 10 175 113 178 48 70 12 39 139 189 162 183 128 164 153 181 29 81 48 153 87 163 45 71 47 125 25 118 68 76 43 102 160 179 33 129 18 95 74 122 66 124 180 193 81 198 151 152 94 113 66 121 165 199 25 118 45 195 4 161 41 176 129 163 16 58 50 171 168 177 171 198 134 194 54 120 56 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '
Test #3:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
200 200 200 179 197 137 140 14 56 101 189 48 188 4 150 55 104 57 65 46 141 172 173 15 144 134 179 28 147 76 175 109 189 43 189 46 100 31 83 57 118 91 159 19 116 6 58 101 190 91 100 142 167 135 162 28 59 133 143 42 150 16 188 105 157 106 192 13 22 184 197 31 184 47 122 75 84 150 159 8 166 70 70 51 13...
output:
1 1 1 9 0 1648 0 8364 0 1 0 0 0 0 0 2 2 0 23 0 2 9 0 5 0 0 216 5 0 9 0 0 0 0 0 0 2 5 9 2 0 0 6 0 0 1 0 1 0 6 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 52 0 418 0 449 0 0 0 0 0 0 2 0 0 0 0 0 1 0 0 1 0 0 1 9476 2 5607 0 1 6 0 1 2 0 0 0 47 0 2 0 1 5 0 0 0 0 0 117 90 0 1 0 90 5 1 5 0 17 0 0 0 47 0 2 207 13099...
result:
ok single line: '1 1 1 9 0 1648 0 8364 0 1 0 0 ...0 30 6 1 0 0 2 6 0 0 0 0 0 0 0 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
200 200 200 1 2 3 17 18 22 23 27 28 40 41 75 76 84 85 86 87 111 112 118 119 123 124 134 135 156 157 166 167 174 175 175 176 199 200 200 1 6 7 14 15 74 75 76 77 83 84 90 91 102 103 116 117 117 118 120 121 123 124 131 132 162 163 166 167 178 179 192 193 200 1 7 8 9 10 39 40 43 44 59 60 82 83 86 87 90 ...
output:
1748 1748 0 0 0 1748 0 0 1748 1748 0 0 0 1748 0 1748 1748 0 0 0 1748 1748 0 0 1748 1748 0 0 1748 0 1748 1748 1748 0 0 1748 0 1748 1748 1748 1748 1748 0 0 0 1748 1748 1748 0 0 0 1748 0 1748 1748 1748 1748 0 1748 0 1748 1748 1748 1748 1748 0 1748 1748 1748 0 1748 1748 1748 0 1748 0 1748 0 1748 1748 0 ...
result:
ok single line: '1748 1748 0 0 0 1748 0 0 1748 ...748 0 0 0 1748 1748 0 1748 0 0 '
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
200 200 200 1 200 8 190 9 186 16 184 32 173 40 152 61 127 89 89 1 200 8 188 11 176 19 173 20 167 28 165 30 161 31 141 32 132 38 131 39 129 59 99 63 89 66 86 72 72 1 200 14 183 32 166 48 138 51 133 99 112 101 108 103 103 1 200 5 184 19 175 25 170 62 148 80 124 104 113 110 110 1 200 5 186 19 185 24 18...
output:
0 308 0 0 0 0 0 0 0 0 0 516 79 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 222 0 0 0 0 0 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2058 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1435 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok single line: '0 308 0 0 0 0 0 0 0 0 0 516 79... 236 0 0 0 0 0 0 0 0 0 0 0 143 '
Test #6:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
200 200 200 1 200 64 156 28 60 81 166 65 186 24 87 94 160 86 108 83 157 99 156 32 75 126 164 153 172 55 157 29 69 27 149 34 114 122 143 164 174 55 66 27 160 67 86 30 154 32 34 21 160 77 95 88 176 54 146 66 150 103 178 28 97 22 192 125 175 32 69 45 194 92 176 149 157 54 153 41 85 35 84 59 193 155 191...
output:
31 230 7730 20 24 24 18 24 1533 24 35 36 26 13388 4194 20 24 18 24 36 2799 65 24 391 24 198 825 100 55 39 20 46 825 24 26 126 24 20 20 20 24 20 55 52 121 20 26 288 24 20 20 270 1252 1420 24 24 24 35 13988 79 24 26 24 38 20 24 20 21 501 24 825 21 31 288 685 1420 24 20 13033 20 36 20 20 695 24 31 501 ...
result:
ok single line: '31 230 7730 20 24 24 18 24 153...14633 26 24 101 24 24 24 20 20 '
Test #7:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
200 200 200 1 197 1 179 1 140 1 137 1 56 1 14 1 189 1 101 1 188 1 48 1 4 1 150 1 55 1 104 1 57 1 65 1 46 1 141 1 173 1 172 1 144 1 15 1 134 1 179 1 147 1 28 1 175 1 76 1 109 1 189 1 189 1 43 1 100 1 46 1 83 1 31 1 118 1 57 1 159 1 91 1 19 1 116 1 58 1 6 1 101 1 190 1 100 1 91 1 167 1 142 1 135 1 162...
output:
22 0 0 0 31 0 0 0 2 32 35 18001 0 0 0 32 0 0 0 0 0 26 34 0 26 0 113 7 0 0 0 0 34 0 32 0 9 16096 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 34 0 19542 0 0 113 33 0 0 0 3569 0 0 0 0 0 0 0 0 0 31 0 33 0 82 0 0 0 0 0 0 214 32 0 0 0 0 0 32 22 187 0 0 0 0 0 0 0 0 32 0 0 0 0 7 0 378 0 0 214 0 0 0 0 9 9 214 478 20372 ...
result:
ok single line: '22 0 0 0 31 0 0 0 2 32 35 1800...1 22 0 0 82 26 91 0 26 0 0 0 9 '
Test #8:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
98 76 54 1 94 5 18 4 65 18 21 29 72 53 67 62 94 5 45 12 41 20 75 17 40 42 88 8 9 33 60 48 98 37 54 16 93 14 15 68 80 57 92 2 94 3 96 68 97 95 96 38 83 55 81 3 50 24 40 14 31 25 41 49 93 14 80 10 90 41 55 45 82 15 41 39 60 16 89 12 81 2 92 30 50 24 44 81 90 14 54 23 91 48 73 29 31 46 95 18 18 9 69 50...
output:
2425 2369 2442 2407 2284 2084 2442 2407 2379 2369 2379 2327 2455 2393 2464 2449 2455 2455 2379 2274 2442 2464 2464 2464 2305 2379 2425 2369 2379 2155 2274 2455 2464 2284 2393 2464 2425 2455 2442 2284 2379 2284 2464 2211 2284 2464 2393 2455 2442 2369 2393 2455 2425 2369
result:
ok single line: '2425 2369 2442 2407 2284 2084 ... 2442 2369 2393 2455 2425 2369 '
Test #9:
score: -11
Runtime Error
input:
1 1 1 1 1 0
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 22
Accepted
Test #18:
score: 22
Accepted
time: 19ms
memory: 4132kb
input:
200000 2000 200000 1 120424 1 117468 1 120525 1 165913 1 120671 1 173649 1 177086 1 160439 1 113657 1 1024 1 172987 1 46445 1 141508 1 72552 1 166171 1 71764 1 129090 1 59615 1 157163 1 44185 1 24107 1 127434 1 157165 1 64831 1 2536 1 138854 1 96084 1 11803 1 162841 1 171842 1 116681 1 47063 1 65296...
output:
319 15786 0 319 185 185 0 4039 0 0 185 319 0 0 0 4039 8795 67453 0 1512 92833 0 0 0 4039 319 185 4039 319 0 0 0 7942 0 185 4039 0 9712 106625656 0 319 6437294 0 185 185 0 0 319 0 1448 1512 185 319 185 0 185 0 185 7169 0 319 0 185 1159434 37373 0 5258 185 0 0 1448 185 185 4039 0 0 0 0 0 0 0 185 0 0 3...
result:
ok single line: '319 15786 0 319 185 185 0 4039... 0 185 0 319 140410 0 185 4039 '
Test #19:
score: 0
Accepted
time: 193ms
memory: 30016kb
input:
200000 200000 200000 1 105714 1 114613 1 25850 1 174511 1 149627 1 40719 1 49551 1 191246 1 49695 1 198423 1 77938 1 133429 1 174342 1 62669 1 19363 1 197263 1 156780 1 133160 1 29943 1 40314 1 7392 1 194703 1 190490 1 151626 1 176326 1 95967 1 175303 1 95044 1 191766 1 182184 1 194258 1 100 1 50906...
output:
4586223 33661520 16925905 51985467 16647357 5094706 13109049 7655073 20948877 63669511 131684346 8135711 3921928 18323346 6482011 4382470 10899030 21564402 10179375 330483347 16332910 40520087 3896118 22405319 5029442 17733161 42118334 15139106949 5517728 7162073 7212437 47546550 93373206 35061660 4...
result:
ok single line: '4586223 33661520 16925905 5198...584532 6394862 3896118 6400722 '
Test #20:
score: 0
Accepted
time: 184ms
memory: 29140kb
input:
200000 200000 200000 1 84862 1 12038 1 107534 1 84884 1 96770 1 142873 1 169266 1 195872 1 107699 1 145577 1 91921 1 97397 1 163387 1 107808 1 105150 1 33461 1 54326 1 139773 1 174400 1 188441 1 58484 1 67025 1 173458 1 73452 1 34682 1 68801 1 163681 1 134541 1 174529 1 103559 1 158417 1 90482 1 152...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '
Test #21:
score: 0
Accepted
time: 127ms
memory: 19992kb
input:
178965 126789 200000 1 155452 1 63409 1 175449 1 173598 1 75512 1 8798 1 101953 1 49531 1 4116 1 72091 1 14404 1 42765 1 114994 1 19243 1 129660 1 57049 1 78438 1 134388 1 98557 1 111950 1 150571 1 167878 1 57531 1 99845 1 145445 1 19371 1 89794 1 143698 1 141739 1 127541 1 61405 1 144152 1 35780 1 ...
output:
11261189812 8447657723 11278055648 11076886083 8983120810 11251543830 10869429837 11141595077 9981744869 11027818562 9393263392 10018022956 10849648971 9664962370 8256449465 8910804964 10159346867 8643010478 11294700519 10100670752 11273638022 10120052702 10169142476 10575075573 9610345824 102271814...
result:
ok single line: '11261189812 8447657723 1127805...843016 11318989179 10641622054 '
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%