QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744285 | #7490. 我回来了 | TheZone | 0 | 0ms | 0kb | C++20 | 1.4kb | 2024-11-13 21:26:28 | 2024-11-13 21:26:28 |
answer
#include<bits/stdc++.h>
#define ll long long
#define re register
#define gc get_char
#define cs const
namespace IO{
inline char get_char(){
static cs int Rlen=1<<22|1;
static char buf[Rlen],*p1,*p2;
return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,Rlen,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline T get(){
char c;
while(!isdigit(c=gc()));T num=c^48;
while(isdigit(c=gc()))num=(num+(num<<2)<<1)+(c^48);
return num;
}
inline int getint(){return get<int>();}
}
using namespace IO;
using std::cerr;
using std::cout;
cs int N=1e3+3;
int n,m,q;
std::vector<int> G[N];
inline void addedge(int u,int v){
G[u].push_back(v);
G[v].push_back(u);
}
int dist[N];
std::bitset<N> f[N][N];
inline void BFS(int S){
static int q[N],qn;
memset(dist+1,0x3f,sizeof(int)*n);
dist[S]=0;q[qn=1]=S;
for(int re i=1;i<=qn;++i){
int u=q[i];
for(int re v:G[u])if(dist[v]>n){
dist[v]=dist[u]+1;
q[++qn]=v;
}
}
for(int re i=1;i<=n;++i)if(dist[i]<n)f[S][dist[i]].set(i);
for(int re i=1;i<n;++i)f[S][i]|=f[S][i-1];
}
signed main(){
#ifdef zxyoi
freopen("I'm back.in","r",stdin);
#endif
n=getint(),m=getint(),q=getint();
while(m--)addedge(getint(),getint());
for(int re i=1;i<=n;++i)BFS(i);
while(q--){
int a=getint();
std::bitset<N> state=0;
while(a--){
int x=getint(),y=getint();
y=std::min(y,n-1);
state|=f[x][y];
}
cout<<state.count()<<"\n";
}
return 0;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 0
Time Limit Exceeded
input:
1000 1000 2 270 992 2 70 531 2 121 832 1 906 1 441 2 133 318 2 679 946 1 419 2 251 979 1 570 1 216 1 159 2 707 909 1 674 2 87 110 1 974 2 96 138 2 561 991 2 425 499 2 752 988 1 190 1 220 1 875 1 802 2 213 955 2 288 547 2 15 205 2 653 961 1 26 1 632 1 840 1 116 1 267 1 189 2 443 707 1 400 1 539 1 441...
output:
result:
Test #2:
score: 0
Time Limit Exceeded
input:
1000 1000 1 999 1 490 2 616 782 1 87 1 610 1 951 2 41 166 2 608 761 1 482 2 240 281 1 920 2 167 399 2 391 444 2 36 366 2 198 472 1 260 1 235 1 335 1 918 1 466 1 821 1 468 2 157 762 1 893 1 670 1 367 2 479 897 1 183 2 145 579 2 68 891 1 78 1 448 1 524 1 973 1 210 1 857 2 16 768 2 447 703 1 764 1 694 ...
output:
result:
Test #3:
score: 0
Time Limit Exceeded
input:
1000 1000 1 476 1 144 2 119 397 2 164 854 2 566 832 1 207 1 749 2 100 828 2 475 517 1 946 1 919 1 378 1 394 1 29 1 788 2 366 980 2 302 573 2 827 908 2 207 926 1 725 2 39 956 2 144 709 1 77 2 675 728 1 243 2 116 540 1 993 1 809 2 75 169 2 802 923 1 897 2 71 141 1 855 2 206 723 2 34 255 1 854 1 134 2 ...
output:
result:
Test #4:
score: 0
Time Limit Exceeded
input:
1000 1000 2 721 833 1 51 2 471 688 1 487 2 698 712 2 247 766 2 9 592 1 439 1 25 1 987 2 309 949 2 397 399 2 54 511 1 370 2 256 678 1 814 2 126 480 1 701 2 906 980 2 258 677 2 362 424 1 261 1 785 1 109 2 335 819 1 324 2 40 734 2 81 448 1 768 2 896 907 1 405 2 154 500 1 555 1 174 1 889 2 236 591 2 186...
output:
result:
Test #5:
score: 0
Runtime Error
input:
100000 1000000 1 8826 1 47779 1 90554 2 42431 42431 2 9379 9379 1 73998 2 18345 18345 1 98104 1 87189 2 9736 9736 1 43752 2 22124 22124 2 23606 23606 1 87492 1 52852 2 73712 73712 2 1019 1019 2 17896 17896 1 1564 2 8503 8503 1 81743 2 15897 15897 2 37020 37020 2 45814 45814 1 3107 2 7782 7782 2 3414...
output:
result:
Test #6:
score: 0
Runtime Error
input:
100000 1000000 2 27188 27188 1 71975 2 37092 37092 1 88379 1 61656 2 39270 39270 2 29252 29252 2 30997 30997 2 23788 23788 2 14573 14573 2 13520 13520 2 62798 62798 2 10952 10952 2 36389 36389 2 22393 22393 2 7028 7028 2 25244 25244 2 17472 17472 1 94430 2 1170 1170 2 31221 31221 2 857 857 1 85851 2...
output:
result:
Test #7:
score: 0
Runtime Error
input:
100000 1000000 2 45549 45549 1 70613 2 42644 42644 2 66369 66369 2 23123 23123 2 18601 18601 2 16403 16403 2 73327 73327 2 25017 25017 2 58174 58174 1 9527 2 3799 3799 1 2658 1 68336 2 42560 42560 2 51701 51701 2 32292 32292 2 55224 55224 2 44301 44301 1 48835 2 67429 67429 2 71281 71281 2 11151 111...
output:
result:
Test #8:
score: 0
Runtime Error
input:
100000 1000000 1 67109 1 66563 1 69271 1 76150 2 29832 29832 1 56049 1 2319 1 39723 1 64002 2 13862 13862 1 79205 1 3328 2 13099 13099 2 38083 38083 1 59237 2 14180 14180 2 74994 74994 1 18115 1 46274 1 59983 1 28288 1 43476 1 94391 1 23902 1 81096 1 5435 1 39572 1 71346 1 82732 1 6945 2 77602 77602...
output:
result:
Test #9:
score: 0
Runtime Error
input:
100000 1000000 1 40343 1 31193 1 96487 1 51217 1 73281 1 63210 1 61015 1 2452 1 51337 1 24975 1 68761 1 98956 1 51257 1 901 1 54590 1 92357 1 60331 1 26736 1 10387 1 5847 1 42883 1 57499 1 97543 1 96521 1 60291 1 52697 1 95385 1 70924 1 63561 1 42117 1 50300 1 21210 1 49086 1 86438 1 64650 1 33693 1...
output:
result:
Test #10:
score: 0
Runtime Error
input:
100000 1000000 1 42756 1 13171 1 82775 1 71817 1 38855 1 52191 1 54364 1 39773 1 9355 1 46135 1 20446 1 85603 1 8386 1 46805 1 28685 1 39101 1 67896 1 64806 1 30868 1 78764 1 16298 1 20258 1 66817 1 18930 1 91730 1 54151 1 92319 1 43285 1 88124 1 33966 1 39746 1 50061 1 84944 1 67688 1 65172 1 71530...
output:
result:
Test #11:
score: 0
Runtime Error
input:
100000 1000000 1 73499 1 81889 1 82753 1 44385 1 73003 1 63622 1 99555 1 56304 1 13586 1 41316 1 35869 1 12616 1 78335 1 84348 1 90858 1 6768 1 82573 1 64491 1 45118 1 58193 1 53357 1 81648 1 4973 1 84150 1 22589 1 70540 1 99417 1 2529 1 19565 1 72552 1 20394 1 25954 1 54266 1 20695 1 58990 1 67578 ...
output:
result:
Test #12:
score: 0
Runtime Error
input:
100000 1000000 1 60835 1 36133 1 65763 1 81275 1 6045 1 87998 1 83691 1 82060 1 69773 1 52034 1 94002 1 76401 1 30782 1 11210 1 16938 1 21216 1 89753 1 53346 1 18548 1 44585 1 92668 1 19700 1 39610 1 48968 1 90915 1 67350 1 54693 1 82923 1 36106 1 87963 1 78415 1 59780 1 44868 1 58038 1 97088 1 8764...
output:
result:
Test #13:
score: 0
Runtime Error
input:
100000 1000000 1 2624 1 429 1 70324 1 94419 1 52098 1 4862 1 2509 1 61264 1 93264 1 24464 1 29655 1 46845 1 66517 1 83250 1 59736 1 65081 1 29677 1 63592 1 60771 1 88032 1 8669 1 48225 1 49383 1 14 1 87086 1 61033 1 21871 1 95109 1 36040 1 97647 1 18264 1 23864 1 85549 1 55345 1 17763 1 44952 1 5596...
output:
result:
Test #14:
score: 0
Runtime Error
input:
100000 1000000 1 5306 1 79209 1 58089 1 68641 1 59709 1 19084 1 1344 1 7788 1 13029 1 88640 1 68240 1 75242 1 75935 1 57539 1 57347 1 67246 1 9132 1 1545 1 64361 1 74925 1 27172 1 60108 1 78412 1 59570 1 29856 1 86240 1 63281 1 3769 1 19067 1 89492 1 1200 1 49532 1 58957 1 24935 1 57301 1 7826 1 512...
output:
result:
Test #15:
score: 0
Runtime Error
input:
100000 100000 1 2663 1 94991 1 14540 1 38935 2 7618 90208 2 6332 93474 1 81964 1 92772 1 64411 2 4770 93295 2 261 92940 2 4375 94105 1 51875 2 3440 96602 2 3107 93825 1 52900 1 81825 1 18215 1 89522 2 5133 95021 1 96449 1 65367 2 1221 91929 1 78330 1 25039 1 83697 1 28411 1 28235 2 5184 95095 1 3156...
output:
result:
Test #16:
score: 0
Runtime Error
input:
100000 100000 1 24884 2 42193 63114 2 12835 78537 2 47571 93329 2 33071 67840 2 31371 33540 2 45542 82514 1 14455 2 36133 66441 2 19447 69233 2 18179 99560 2 12111 50274 2 82544 85932 2 49284 70869 2 17192 68542 2 12462 52795 2 66689 68770 2 75965 82259 2 52475 86313 2 5254 5710 2 37703 83293 1 7214...
output:
result:
Test #17:
score: 0
Runtime Error
input:
100000 100000 1 81747 2 31756 74163 2 13561 58425 2 38121 63653 2 49749 52757 2 12465 89247 1 14763 1 13440 1 71435 2 76886 93001 2 52822 57153 1 97449 2 6324 10017 2 25714 69181 1 86055 2 15991 36145 1 43602 1 48123 2 32589 92016 2 53936 71468 2 48484 51289 2 4982 9323 2 8943 60747 1 3064 2 20760 5...
output:
result:
Test #18:
score: 0
Runtime Error
input:
100000 100000 1 38764 1 61409 2 3016 54683 1 45867 1 36421 1 22224 1 96005 1 85738 1 36687 1 8821 2 50514 65192 1 83652 1 64096 2 977 85114 2 34818 78357 1 69503 1 12890 1 78346 1 90700 1 10743 1 1859 1 60451 1 22251 1 16291 1 41259 1 10052 2 1257 37427 2 4379 43742 1 45422 2 43786 96870 1 83847 2 3...
output:
result:
Test #19:
score: 0
Runtime Error
input:
100000 1000000 2 4911 50410 1 18088 2 5195 60114 1 66894 1 65264 2 53839 57562 1 64194 1 91 1 11325 2 2404 84967 2 15644 59062 2 7662 22604 1 26614 1 42520 1 19543 1 16866 2 17622 69362 1 71238 2 28270 75604 2 16675 96147 1 51283 2 11061 38681 1 24535 1 22493 1 39994 2 81216 92230 2 9388 65396 1 465...
output:
result:
Test #20:
score: 0
Runtime Error
input:
100000 1000000 1 53425 2 30982 39737 1 67975 2 74292 83400 1 82761 2 45128 50241 1 96414 2 68516 81468 2 18342 21086 1 70683 1 91858 1 72179 1 91048 2 48543 51109 1 26684 2 54936 71148 1 8139 2 24875 58961 2 44353 92619 2 32778 78210 2 13383 83090 2 6616 31035 2 68739 98635 1 38315 1 97083 2 77033 9...
output:
result:
Test #21:
score: 0
Runtime Error
input:
100000 1000000 1 17727 1 15420 2 9034 93216 2 14196 70538 2 18132 28441 2 12607 51931 1 32242 2 4334 97259 2 11727 59701 1 92605 2 25817 99001 2 66613 94016 2 11924 44027 1 95138 2 57853 92274 1 60723 2 7848 65584 2 7913 57275 2 2983 97596 1 19883 2 50838 61901 2 46102 55845 2 8990 90056 2 18614 844...
output:
result:
Test #22:
score: 0
Runtime Error
input:
100000 1000000 2 30380 90974 2 19653 98082 2 35889 38945 2 5632 77153 2 12370 93208 2 41484 94976 2 30647 76253 2 16639 46690 2 2326 65175 2 54409 70309 1 1 1 2 2 26996 37077 2 18322 85952 2 71036 82796 2 16794 22081 2 21893 26538 2 54398 63568 2 56557 92249 2 69039 83022 2 55448 62890 2 27603 51211...
output:
result:
Test #23:
score: 0
Runtime Error
input:
100000 1000000 2 42 91533 2 6335 93500 2 9170 94276 2 1479 90642 2 6963 95536 2 5706 91855 2 3282 93173 2 9962 99509 2 2996 98058 2 4828 94564 2 2392 95396 2 3903 99847 2 293 97618 2 7422 91284 2 9719 90105 2 5448 98274 2 4772 98462 2 1870 90088 1 1 2 5668 93701 2 7036 90106 2 8704 96189 2 1323 9966...
output:
result:
Test #24:
score: 0
Runtime Error
input:
100000 1000000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59...