QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#420779 | #8705. 圣遗物 | Williamxzh | 35 | 744ms | 22388kb | C++23 | 2.5kb | 2024-05-24 21:56:07 | 2024-05-24 21:56:09 |
Judging History
answer
#include <bits/stdc++.h>
#define il inline
#define pii pair<int,int>
#define fi first
#define se second
#define pdd pair<double,double>
using namespace std;
const double eps=1e-8;
il double ab(double x){return x>0?x:-x;}
il int isint(double x){return ab(x-int(x))<eps;}
il void cmax(int &x,int y){x=(x>y?x:y);}
typedef long long ll;
const int N=50005,M=11,inf=1e9;
int tid,T,n,m,ck,l[N],f[N],g[N],ans[N],id[N][M],d[M];double A,B;pii pre[501][50001];pdd a[N][M],c[M];
il void print(int v){
int x=v;
for(int i=n;i;--i) ans[i]=pre[i][x].fi,x=pre[i][x].se;
for(int i=1;i<=n;++i) printf("%d ",ans[i]);puts("");
}
int cur;
il bool cmp(int x,int y){return a[cur][x]<a[cur][y];}
int x,y,z,p,q,s,t;double u,v,w,mx;
int main(){
scanf("%d%d",&tid,&T);
while(T--){
scanf("%d",&n);ck=1;
for(int i=1;i<=n;++i){
scanf("%d",&l[i]);
for(int j=1;j<=l[i];++j) scanf("%lf%lf",&a[i][j].fi,&a[i][j].se),d[j]=j,id[i][j]=j;
/*cur=i;sort(d+1,d+1+l[i],cmp);sort(a[i]+1,a[i]+1+l[i]);
u=0,x=0;
for(int j=l[i];j;--j){
if(a[i][j].se>u) c[++x]=a[i][j],id[i][x]=d[j];
u=max(u,a[i][j].se);
}
for(int j=1;j<=l[i];++j) a[i][j]=c[j];*/
for(int j=1;j<=l[i];++j) ck&=isint(a[i][j].fi)&isint(a[i][j].se);
}
scanf("%d",&m);
if(ck){
s=0,f[0]=0;
for(int i=1;i<=n;++i){
z=0;for(int j=1;j<=l[i];++j) cmax(z,int(a[i][j].fi));
for(int j=0;j<=s;++j) g[j]=f[j],f[j]=-inf;
for(int j=s+1;j<=s+z;++j) f[j]=-inf;
for(int j=1;j<=l[i];++j)
for(int k=0;k<=s;++k){
x=int(a[i][j].fi)+k,y=g[k]+int(a[i][j].se);
if(f[x]<y) f[x]=y,pre[i][x]={id[i][j],k};
}
s+=z;
}
while(m--){
scanf("%lf%lf",&A,&B);mx=0,p=0;
for(int i=0;i<=s;++i){
w=1.00*(A+i)*(B+f[i]);
if(w>mx) mx=w,p=i;
}
print(p);
}
}
}
return 0;
}
/*
1 1
5
3
98 71 28 7 62 13
3
29 23 65 70 34 95
3
59 41 64 43 92 59
3
73 75 99 96 43 2
3
14 24 5 7 54 13
10
8.06 47.73
183.28 351.90
83.70 90.40
34.00 127.83
216.88 312.31
182.09 349.61
266.90 320.28
84.18 420.91
33.26 145.00
118.07 354.22
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 0ms
memory: 10080kb
input:
1 100 5 3 98 71 28 7 62 13 3 29 23 65 70 34 95 3 59 41 64 43 92 59 3 73 75 99 96 43 2 3 14 24 5 7 54 13 10 8.06 47.73 183.28 351.90 83.70 90.40 34.00 127.83 216.88 312.31 182.09 349.61 266.90 320.28 84.18 420.91 33.26 145.00 118.07 354.22 5 3 25 63 11 75 63 31 3 94 53 38 89 46 23 3 49 99 12 80 52 4 ...
output:
1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 1 3 1 1 2 1 3 1 1 2 1 3 1 1 2 1 2 1 1 2 1 2 1 1 2 1 2 1 1 2 1 3 1 1 2 1 3...
result:
ok OK, Accepted
Test #2:
score: 15
Accepted
time: 3ms
memory: 8028kb
input:
1 100 5 3 100 44 62 34 64 47 3 9 52 94 73 70 100 3 8 10 87 17 53 61 3 89 88 5 36 2 35 3 76 13 90 71 45 89 10 33.88 69.11 120.74 410.51 119.96 340.70 82.73 416.98 27.98 30.22 69.37 110.99 27.26 153.77 36.29 164.04 56.99 241.65 158.23 272.16 5 3 87 41 60 98 33 50 3 7 83 3 43 78 6 3 88 42 98 97 72 91 3...
output:
1 3 3 1 2 1 2 3 1 2 1 2 3 1 2 1 2 2 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 1 2 1 3 3 1 2 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 2 3 1 2 1 2 3 1 2 3 2 3 1 2 1 2 3 1 2 3 2 3 1 2 3 2 3 1 2 3 3 3 3 2 3 3 3 3 2 3 3 3 3 2 3 3 3 3 2 3 3 3 3 2 3 3 3 3 2 3 3 3 3 2 3...
result:
ok OK, Accepted
Subtask #2:
score: 20
Accepted
Test #3:
score: 20
Accepted
time: 22ms
memory: 22388kb
input:
2 100 27 9 58 21 76 52 99 40 22 25 26 38 25 65 80 47 59 83 12 7 10 87 40 54 90 65 88 86 75 92 22 5 70 53 88 72 34 25 55 7 66 10 8 69 28 19 80 41 17 15 40 82 9 57 77 43 79 63 24 39 62 30 10 38 41 5 45 55 80 93 63 96 46 98 50 31 48 49 49 77 63 46 54 10 99 11 33 21 69 25 9 17 93 30 87 16 22 93 97 36 84...
output:
8 4 8 4 10 10 6 2 6 7 10 6 8 4 10 4 5 6 4 5 9 3 7 7 9 10 2 3 4 8 4 10 10 6 10 6 7 10 6 8 1 10 4 5 5 4 5 9 3 7 7 9 10 2 3 4 8 4 10 10 6 10 3 7 10 6 8 1 10 4 5 5 4 5 3 3 7 7 9 5 2 3 4 8 4 10 10 6 10 3 7 10 6 8 1 10 4 5 5 4 5 3 3 7 7 9 5 2 3 4 8 4 10 10 6 10 6 7 10 6 8 1 10 4 5 5 4 5 3 3 7 7 9 10 2...
result:
ok OK, Accepted
Test #4:
score: 20
Accepted
time: 27ms
memory: 20296kb
input:
2 100 20 9 87 13 97 57 97 11 92 28 57 82 84 72 56 15 10 21 25 24 9 58 100 94 59 25 87 100 26 47 32 58 46 16 25 65 76 54 65 9 42 3 17 26 44 22 20 83 11 93 7 51 87 7 85 5 96 23 8 26 67 18 14 24 74 8 90 9 90 38 75 33 7 7 40 8 22 25 32 36 95 90 27 2 25 31 82 4 98 77 100 75 8 7 16 94 93 85 100 77 41 90 7...
output:
2 2 9 6 3 2 3 8 1 5 9 3 3 8 3 9 8 5 1 8 6 1 9 6 3 2 3 8 1 5 9 3 3 8 3 9 7 5 9 8 2 2 9 6 3 2 3 8 1 5 9 3 3 8 3 9 8 5 9 8 6 1 9 6 3 2 3 8 1 5 9 3 3 8 3 9 7 5 9 8 2 2 9 6 3 2 3 8 1 5 9 3 3 8 3 9 8 5 9 8 2 2 9 6 3 2 3 8 1 5 9 3 3 8 3 9 8 5 9 8 2 2 9 6 3 2 3 8 1 5 9 3 3 8 3 9 8 5 9 8 6 1 9 6 3 2 3...
result:
ok OK, Accepted
Test #5:
score: 20
Accepted
time: 24ms
memory: 20256kb
input:
2 100 14 10 60 79 33 78 95 31 45 12 68 96 30 21 66 62 80 43 44 100 20 16 8 25 11 64 47 10 5 39 51 28 12 67 81 86 85 98 22 10 91 99 87 11 61 42 57 87 100 11 4 54 7 50 25 83 16 40 52 38 9 89 100 19 88 4 75 10 15 85 10 98 9 80 38 17 81 48 57 10 62 72 40 10 31 64 79 45 63 10 7 15 78 93 6 69 97 66 71 87 ...
output:
5 7 1 1 9 2 3 2 5 5 6 7 1 10 5 7 1 1 7 2 3 2 5 5 6 7 1 10 3 7 1 1 9 2 3 2 5 5 6 7 1 10 5 7 1 1 9 2 3 2 5 5 6 7 1 10 3 7 1 1 9 2 3 2 5 5 6 7 1 10 5 7 1 1 9 2 3 2 5 5 6 7 1 10 3 7 1 1 9 2 3 2 5 5 6 7 1 10 5 7 1 1 9 2 3 2 5 5 6 7 1 10 5 7 1 1 9 2 3 2 5 5 6 7 1 10 5 7 1 1 9 2 3 2 5 5 6 7 1 10 ...
result:
ok OK, Accepted
Subtask #3:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
input:
3 100 496 9 62 33 67 95 25 42 68 17 2 18 65 76 39 78 27 37 55 75 9 97 77 28 91 37 55 83 37 34 82 12 29 58 78 28 6 81 35 8 17 22 2 52 92 14 4 59 82 7 23 37 75 67 39 87 8 62 70 17 5 7 95 84 73 36 35 17 85 84 61 89 69 9 1 80 10 60 37 75 51 64 42 24 89 3 74 56 82 89 87 66 10 79 23 29 19 38 15 14 33 85 1...
output:
2 1 7 8 8 6 3 7 3 6 4 5 1 4 4 1 2 4 3 2 3 2 4 7 8 6 6 3 3 7 1 6 5 2 8 7 2 5 4 2 6 2 2 8 7 9 2 4 4 8 4 6 2 2 7 2 1 3 2 6 7 8 3 1 2 1 8 3 5 7 1 5 5 2 1 7 8 8 7 1 6 3 5 6 4 10 8 7 2 7 4 7 8 3 2 1 2 7 6 4 1 10 7 6 1 5 5 6 4 9 5 9 2 1 3 3 3 1 4 4 3 2 2 5 6 7 1 7 2 3 1 7 4 9 2 9 8 9 5 5 10 8 5 8 4 4 4 9 5...
result:
Subtask #4:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 744ms
memory: 13620kb
input:
4 100 450 10 30.37 69.63 50.77 49.23 94.68 5.32 36.02 63.98 30.92 69.08 60.25 39.75 94.63 5.37 61.38 38.62 91.27 8.73 28.94 71.06 8 74.79 25.21 8.63 91.37 49.25 50.75 27.02 72.98 72.03 27.97 52.44 47.56 41.20 58.80 44.26 55.74 9 58.02 41.98 35.82 64.18 99.61 0.39 59.26 40.74 47.09 52.91 87.65 12.35 ...
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #5:
score: 0
Time Limit Exceeded
Test #15:
score: 0
Time Limit Exceeded
input:
5 100 400 9 1.57 81.69 17.89 66.70 65.51 20.96 14.19 70.10 73.04 13.58 25.01 60.09 57.73 28.55 18.21 66.41 41.57 44.34 8 42.15 15.21 45.93 11.16 27.62 30.65 39.90 17.60 9.87 47.93 51.17 5.44 14.72 43.43 42.11 15.26 9 15.72 52.00 32.33 36.33 7.60 59.51 39.83 28.78 58.75 9.42 30.01 38.51 24.14 44.06 0...