QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114259 | #5976. Fairland | zwh2008 | 0 | 6337ms | 29028kb | C++14 | 1.1kb | 2023-06-21 19:33:10 | 2023-06-21 19:33:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
int n,D,now,cnt,Case,fa[N],h[N];
bool ok[N],vis[N];
struct node{int x,d;}a[N];
struct edge{int n,t;}e[N];
void add(int x,int y){e[++cnt]={h[x],y},h[x]=cnt;}
void dfs1(int x){ok[x]=1,now++;for(int i=h[x];i;i=e[i].n)if(vis[e[i].t])dfs1(e[i].t);}
void dfs2(int x){ok[x]=0,now--;for(int i=h[x];i;i=e[i].n)if(ok[e[i].t])dfs2(e[i].t);}
void Add(int x){vis[x]=1;if(x==1||ok[fa[x]])dfs1(x);}
void Del(int x){vis[x]=0;if(ok[x])dfs2(x);}
void solve() {
int as,cs,rs,am,cm,rm;a[1].x=1,now=cnt=0,memset(h,0,sizeof(h));
scanf("%d%d%d%d%d%d%d%d%d%d",&n,&D,&a[1].d,&as,&cs,&rs,fa+1,&am,&cm,&rm);
for(int i=2;i<=n;i++)a[i]={i,(1ll*a[i-1].d*as+cs)%rs},fa[i]=(1ll*fa[i-1]*am+cm)%rm%(i-1)+1,add(fa[i],i);
sort(a+1,a+n+1,[](node &x,node &y){return x.d<y.d;});
int j=0,ans=0;
for(int i=1;i<=n;i++) {
while(j<n&&a[j+1].d<=a[i].d+D)Add(a[++j].x);
ans=max(ans,now),Del(a[i].x);
}
printf("Case #%d: %d\n",++Case,ans);
}
int main() {
int tt;scanf("%d",&tt);
while(tt--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 18ms
memory: 14104kb
input:
100 863 737 147 1 1 826 830 1 1 831 186 768 267 527 792527137 526 81 13 460856586 342 848 696 135 1 1 787 813 1 1 814 987 668 157 1 1 892 255 326 108399179 710 728 169 323 210 682026321 585 750 85 977096686 799 915 725 167 1 1 866 813 1 1 814 816 381 670 1 1 744 429 1 1 430 688 569 579 848 252088721...
output:
Case #1: 764 Case #2: 186 Case #3: 748 Case #4: 764 Case #5: 685 Case #6: 722 Case #7: 148 Case #8: 89 Case #9: 824 Case #10: 13 Case #11: 2 Case #12: 15 Case #13: 917 Case #14: 3 Case #15: 104 Case #16: 831 Case #17: 1 Case #18: 9 Case #19: 840 Case #20: 855 Case #21: 260 Case #22: 733 Case #23: 95...
result:
wrong answer 1st lines differ - expected: 'Case #1: 710', found: 'Case #1: 764'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 6337ms
memory: 29028kb
input:
100 1000 700 1 1 1 1000 999 1 1 1000 868238 873094 175212 1 946155217 409436 809287 1 1 809288 854112 678623 130672 1 1 789040 845767 1 1 845768 814744 420144 420003 1 1 803202 800344 1 1 800345 864316 383539 632857 1 1 703161 615175 55 522100274 984097 877988 440499 469030 1 1 839327 469558 1 1 469...
output:
Case #1: 701 Case #2: 868238 Case #3: 743056 Case #4: 383199 Case #5: 149206 Case #6: 479161 Case #7: 1 Case #8: 986 Case #9: 176575 Case #10: 1000000 Case #11: 9 Case #12: 775976 Case #13: 816914 Case #14: 135951 Case #15: 121338 Case #16: 973999 Case #17: 738264 Case #18: 727633 Case #19: 813175 C...
result:
wrong answer 3rd lines differ - expected: 'Case #3: 666711', found: 'Case #3: 743056'