QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#176492 | #2732. Vera and Modern Art | lgswdn | 5 | 6ms | 19500kb | C++14 | 2.6kb | 2023-09-11 18:34:43 | 2023-09-11 18:34:44 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
ll read() {
ll x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=2e5+5;
int n,m,ans[N],s[N<<6],tx=1,ty=1;
int cx[N<<6][2],cy[N<<6][2];
ll c[N];
struct opt {ll y; int w;};
vector<opt> p[N];
vector<int> e[N];
void addx(ll x,ll y,int w) {
int h=topbit(x),u=1;
rep(i,0,h-1) {
bool b=x&(1ll<<i);
if(!cx[u][b]) cx[u][b]=++tx;
u=cx[u][b];
}
rep(b,0,1) {
if(!cx[u][b]) cx[u][b]=++tx;
int v=cx[u][b];
p[v].eb((opt){y,w});
}
}
void addy(ll y,int w) {
int h=topbit(y),u=1;
rep(i,0,h-1) {
bool b=y&(1ll<<i);
if(!cy[u][b]) cy[u][b]=++ty;
u=cy[u][b];
}
rep(b,0,1) {
if(!cy[u][b]) cy[u][b]=++ty;
int v=cy[u][b]; s[v]+=w;
}
}
void qryx(ll x,int id) {
int h=topbit(x),u=1;
rep(i,0,h) {
bool b=x&(1ll<<i);
if(!cx[u][b]) break;
u=cx[u][b];
}
e[u].eb(id);
}
int qryy(ll y) {
int h=topbit(y),u=1,ans=0;
rep(i,0,h) {
bool b=y&(1ll<<i);
if(!cy[u][b]) break;
u=cy[u][b], ans+=s[u];
}
return ans;
}
void dfs(int u) {
if(!u) return;
for(opt f:p[u]) addy(f.y,f.w);
for(int g:e[u]) ans[g]=qryy(c[g]);
dfs(cx[u][0]), dfs(cx[u][1]);
for(opt f:p[u]) addy(f.y,-f.w);
}
signed main() {
n=read(), m=read();
rep(i,1,n) {
ll x=read(), y=read(), val=read();
addx(x,y,val);
}
rep(i,1,m) {
ll x=read(); c[i]=read();
qryx(x,i);
}
dfs(1);
rep(i,1,m) printf("%d\n",ans[i]);
return 0;
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 6ms
memory: 17480kb
input:
2000 2000 863052900322308438 585461919958425547 2603 526750366165658033 509066789767077405 7436 649435956957351345 979682059927434256 9868 830905178259479463 747566590013542340 5131 322888213739078622 787599796792931260 5343 387720552768190527 707990974300483296 5456 995284968988447437 6559282648306...
output:
8539 8343 854 5294 9664 3968 9107 4499 8382 1452 8392 5492 2149 8619 5437 9251 893 8792 6336 7180 5110 766 8539 2222 4701 3956 5173 8460 3069 8600 5324 6804 1064 3307 229 1199 2054 7956 3350 6974 6551 7179 198 4066 4633 356 9134 7184 1170 2616 8475 6425 7126 7366 8558 3044 2531 3342 2920 9428 9287 9...
result:
ok 2000 lines
Test #2:
score: 0
Accepted
time: 5ms
memory: 17308kb
input:
2000 2000 708742429912472382 657489792224291690 2908 786445592645402997 366970491269851157 6413 644824623743061293 878556194838199508 895 854342240174626476 506630596144597431 3522 490284640060217554 561102830959103106 1938 608637915455246516 881134709624987778 656 706875321854362355 325801426255009...
output:
4369 6940 5158 4159 2963 8728 3640 4731 7105 8018 2952 7355 3651 7565 6115 7246 4391 2844 9272 5265 4486 2950 6607 1193 1813 6611 9862 5653 5265 1911 337 5220 1092 3241 4696 8942 4153 1459 2985 6977 2392 5253 8954 859 2217 2389 1386 4079 4543 1221 3222 1353 3892 5028 8944 8174 7824 8078 539 4155 505...
result:
ok 2000 lines
Test #3:
score: 0
Accepted
time: 3ms
memory: 16568kb
input:
2000 2000 10 60819039 5702 3012786602512671 7176094883 852 25485144 7 5861 3098207184192 17344 755 87 158884 9867 30509 446840 1040 13706101785 74 4785 702 31473101 4340 729 297538590445889743 1787 20734250687 14086930566 5671 173623981 253459185965263 29 469839 6715142 1325 1909439723762 1617684566...
output:
15960 13249 15766 7893 25482 8286 0 26265 20374 10804 9781 4077 1518 6853 12495 14197 24779 236 7625 11412 27744 7625 13441 6402 13854 14136 27211 8286 0 9260 5925 10601 8094 16814 7085 10157 22502 4671 18957 9893 12802 0 17016 21306 7625 7379 22076 7625 0 13960 7625 7625 7625 0 8814 23926 1932 4041...
result:
ok 2000 lines
Test #4:
score: 0
Accepted
time: 6ms
memory: 17144kb
input:
2000 2000 45894 13541 2711 37412030 487660 4900 30196454574 389817 211 119345 42985683221218 7389 127 1728973986561263 3752 790840 12847262810 3141 1356409281996192 65686349678 4462 1785396 5 487 7967558 340996377158 7542 111 29412076648876 4010 23355184283436377 170170991 9115 361099 90361263738019...
output:
21038 17108 13598 15804 9664 15799 17354 10054 21136 30604 9664 18887 18887 18887 21038 24457 28141 18887 16814 9664 20230 10116 4960 19179 21136 26488 9664 18887 10991 33253 13039 9664 9664 17878 25531 9664 12821 18581 16814 10472 13546 10742 24756 22808 15804 22519 21136 9664 37079 12349 17108 185...
result:
ok 2000 lines
Test #5:
score: 0
Accepted
time: 3ms
memory: 17436kb
input:
2000 2000 2138644 18 7719 1124820 13367832532490 945 90991704 160 1366 49629002251270303 529067355 9481 30839499163862 11316 446 19237082202654687 55 1479 13341522551 1375266 4600 27466634768416 2562317 875 1000000000000000000 7204 1533 6070750319 310 195 128 38438648820523 5833 4834369105 106638377...
output:
39146 37573 23460 40491 8593 8593 8894 38131 37429 34220 42489 7797 8593 32606 25865 15529 8645 34871 34220 15529 34220 39094 39214 34220 34545 25865 34545 46147 15529 32606 15529 15529 15529 34220 32606 15529 34994 8593 8946 24883 15529 51076 15529 13420 34220 15396 42489 34942 34220 15482 33861 86...
result:
ok 2000 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 19500kb
input:
2000 2000 21279519767 1211 4932 10773909809 23009589064105 7530 5646830 1 7575 69104 3032892120148480 1107 173253389887 62 4388 68925773 2213637099 8369 87157 155 5066 569667900962 1762878 9540 28627 15143434019770 9986 17417579267458 6954805104 1652 60461726535752 13246230 6377 3119 1212914361927 3...
output:
9877 14992 6052 7953 8687 0 14262 10437 0 0 0 8210 12694 856 0 5127 2315 0 8210 5377 3812 6052 6052 0 0 2315 6052 6642 0 856 4271 2315 0 2315 14262 6052 856 6052 0 9877 856 0 7312 14262 3171 8210 2315 2315 0 8210 14262 8210 5377 0 9384 0 8210 4271 3812 2315 8687 14262 0 16735 6052 8210 14262 0 2315 ...
result:
ok 2000 lines
Test #7:
score: 0
Accepted
time: 0ms
memory: 17276kb
input:
2000 2000 2137 38073 6725 355 18 8213 5830587504 2 2648 78 5 8264 424149824559596 72093549985 2933 1281696708970614 53221 6426 3 589231223 2945 678 15738720472 7289 91057713696519 1460584943111 8661 1555508538242 1790149551118669 2372 20382435790632 358326815974203 3473 96468543157 480 7175 28077249...
output:
3479 12949 4332 4332 11551 19564 9284 32807 32807 13388 11551 5652 12610 12563 9284 4332 12146 12610 9284 12949 12146 6920 7219 9284 11584 4332 4332 21659 0 6920 17791 11252 21618 4365 11584 4332 12563 4332 25265 17791 19564 4332 12610 32807 7219 11551 11584 12563 5652 11252 4332 11252 5652 11584 69...
result:
ok 2000 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 17492kb
input:
2000 2000 5851786354176 4040428 2265 2090124767 9823 6987 67 119398 7142 404045861381842460 3 4115 47 323339427358234 8545 19 45369 3431 8088146 103 2182 95668676 1 3668 1324931120984 199200407955310 1645 1732727909 1721354791 9459 57549964551968961 7524884872 3213 11920489260 535832679744 3984 4026...
output:
9554 16934 16870 20670 16187 9554 9554 11749 16363 9824 11749 9554 16187 16870 9554 9554 18654 9554 22961 16187 18654 11749 17359 9554 16159 18654 18654 16187 18654 18654 13954 9554 9554 16187 9554 9554 9554 13861 18654 9554 16187 9554 12571 23608 13954 12571 9554 11749 9554 20670 23608 9554 9554 18...
result:
ok 2000 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 16456kb
input:
2000 2000 535900078 28730525 2952 102 17650 9358 4535 3384757114 9082 12867229 174904954970818796 3058 1656 1380114853 5613 263494408554410 28685 7005 215030 1462180803 2810 812 3734266673996462 3464 452828 33 5538 7503915 436 386 78255526600570122 1701255 3079 4415561 159069185 5601 11952238 188369...
output:
0 6174 8468 9615 5266 0 0 2789 0 5266 5266 0 9615 0 9615 9615 5266 5266 5266 9615 0 5266 9615 9615 0 9615 0 0 14345 8151 5266 10765 8487 5266 9615 317 0 0 11440 5266 0 2789 9615 5266 0 0 8487 0 0 5925 9615 5266 9615 8487 0 5266 14345 9615 0 0 0 9615 9615 8487 0 17766 0 6625 17766 5266 0 0 0 2789 120...
result:
ok 2000 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 16736kb
input:
2000 2000 131890964963 2620980678199514 5450 48642228835614046 533511702086 2191 107286339040564510 228499 3277 1 75542183 285 767960049 36 4728 6306312438 3565071862123 9346 14531963 352 9415 1315928 3 8018 11220423379745349 7033730184 3518 55265770561030 1593709490903 4700 359015303917077 39678719...
output:
15575 5686 4500 0 12877 4500 7374 7248 0 0 0 0 4626 4500 7248 4500 4500 5686 7248 0 4500 4500 15819 7248 4500 2116 4626 2748 4626 15008 0 8727 4500 4500 7248 7248 4500 6281 20880 26309 4500 15008 0 6281 4626 7374 7248 4500 4500 7374 0 4500 5686 15625 12498 5686 0 5686 4500 5686 4500 9579 15008 26309...
result:
ok 2000 lines
Subtask #2:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
input:
200000 200000 859422066098830991 1 4914 642859986446449532 1 376 719948192245038320 1 5246 326732866086294827 1 4979 927556748609838327 1 6477 966962857351020963 1 8843 935451737400114761 1 4518 455550602517312533 1 76 542921280411063861 1 5774 838451513131566371 1 7145 981836072584124918 1 5220 346...
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #21:
score: 0
Runtime Error
input:
100000 100000 504849608 374110485 5954 845294749 269058441 4860 818642530 341615985 5355 779408178 612082365 3722 392690513 971162916 6982 999625668 824426927 1261 966352187 983873183 722 517369231 806105700 3569 905389201 907084792 503 582692052 424611071 9044 373185376 783728614 4518 285689031 604...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%