QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#329104 | #1840. K-onstruction | qzez | AC ✓ | 302ms | 11900kb | C++14 | 1.5kb | 2024-02-16 13:29:37 | 2024-02-16 13:29:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(a) (a).begin(),(a).end()
#ifdef DEBUG
template<class T>
ostream& operator << (ostream &out,vector<T> a){
out<<'[';
for(T x:a)out<<x<<',';
return out<<']';
}
template<class T>
vector<T> ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<class T>
void debug(T x){
cerr<<x<<endl;
}
template<class T,class...S>
void debug(T x,S...y){
cerr<<x<<' ',debug(y...);
}
#else
#define debug(...) void()
#endif
mt19937 rnd(time(0));
const int M=1.3e5+10,N=2e6,Q=1e3+10;
int q,a[Q],id[N];
uint f[M];
vector<int>ans[Q];
int rd(int l,int r){
return rnd()%(r-l+1)+l;
}
int main(){
scanf("%d",&q);
for(int i=1;i<=q;i++)scanf("%d",&a[i]);
int T=0;
set<int>ret;
for(int i=1;i<=q;i++)ret.insert(i);
for(;!ret.empty();T++){
memset(f,0,sizeof f);
int m=1.5e3,n=29,sum=0;
vector<int>p{0,m};
for(int i=1;i<n;i++){
int x;
do x=rd(1,m);while(find(all(p),x)!=p.end());
p.push_back(x);
}
sort(all(p));
f[0]=1;
vector<int>num;
for(int i=1;i<=n;i++){
int x=p[i]-p[i-1];
sum+=x;
for(int j=sum;j>=x;j--)f[j]+=f[j-x];
num.push_back(x);
}
for(int i=0;i<=sum;i++)id[f[i]+1]=i;
for(auto it=ret.begin();it!=ret.end();){
int i=*it;
if(id[a[i]])ans[i]=num,ans[i].push_back(-id[a[i]]),it=ret.erase(it);
else ++it;
}
}
for(int i=1;i<=q;i++){
printf("%ld\n",ans[i].size());
for(int x:ans[i])printf("%d ",x);
puts("");
}
debug(T,1.0*clock()/CLOCKS_PER_SEC);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 8808kb
input:
2 3 16
output:
30 20 67 111 5 8 45 36 27 84 50 42 81 19 7 79 13 5 5 12 23 108 255 21 33 22 63 1 72 186 -1492 30 20 67 111 5 8 45 36 27 84 50 42 81 19 7 79 13 5 5 12 23 108 255 21 33 22 63 1 72 186 -1473
result:
ok correct (2 test cases)
Test #2:
score: 0
Accepted
time: 3ms
memory: 10444kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
30 20 67 111 5 8 45 36 27 84 50 42 81 19 7 79 13 5 5 12 23 108 255 21 33 22 63 1 72 186 -1498 30 20 67 111 5 8 45 36 27 84 50 42 81 19 7 79 13 5 5 12 23 108 255 21 33 22 63 1 72 186 -1500 30 20 67 111 5 8 45 36 27 84 50 42 81 19 7 79 13 5 5 12 23 108 255 21 33 22 63 1 72 186 -1492 30 20 67 111 5 ...
result:
ok correct (1000 test cases)
Test #3:
score: 0
Accepted
time: 7ms
memory: 10352kb
input:
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 ...
output:
30 33 53 35 32 66 28 108 142 61 11 9 81 15 47 181 1 100 103 8 26 131 17 51 9 41 8 89 6 8 -1385 30 42 103 25 8 123 82 165 24 7 52 121 26 8 40 129 8 79 59 4 44 21 89 84 35 45 3 10 13 51 -1377 30 40 70 37 21 58 6 24 120 6 29 170 125 49 7 15 32 37 51 35 53 6 136 81 27 207 19 9 24 6 -1388 30 54 96 8 4...
result:
ok correct (1000 test cases)
Test #4:
score: 0
Accepted
time: 302ms
memory: 10316kb
input:
1000 993583 891827 976796 828946 983149 933824 989543 985227 981826 917123 995813 961139 945833 875509 983784 994507 998827 941562 865682 996623 971299 953499 918651 971707 966313 980053 996657 976037 870307 935389 927903 998826 923969 987837 905739 996643 979733 952467 881278 929789 956447 976709 9...
output:
30 25 66 39 2 74 128 45 35 120 101 40 23 4 8 42 19 5 27 129 71 7 20 179 78 138 7 30 2 36 -840 30 17 13 53 44 99 114 64 13 2 17 78 43 43 112 6 31 40 56 50 137 21 161 2 56 63 79 1 12 73 -888 30 10 21 13 54 151 60 22 48 4 8 124 14 12 10 50 12 91 20 95 16 8 28 41 76 118 32 137 197 28 -836 30 4 147 29...
result:
ok correct (1000 test cases)
Test #5:
score: 0
Accepted
time: 25ms
memory: 10420kb
input:
1000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 ...
output:
30 38 41 77 10 11 10 40 19 44 151 60 63 84 4 112 49 1 137 67 37 10 10 112 54 65 33 64 89 8 -1280 30 32 12 31 37 18 2 147 54 34 75 7 26 44 4 74 46 65 148 85 44 67 26 19 2 95 30 8 135 133 -1294 30 20 23 13 45 60 24 27 181 141 273 10 72 22 40 17 88 45 5 5 119 20 1 95 31 4 1 72 4 42 -1346 30 16 29 88...
result:
ok correct (1000 test cases)
Test #6:
score: 0
Accepted
time: 122ms
memory: 11536kb
input:
1000 99001 99002 99003 99004 99005 99006 99007 99008 99009 99010 99011 99012 99013 99014 99015 99016 99017 99018 99019 99020 99021 99022 99023 99024 99025 99026 99027 99028 99029 99030 99031 99032 99033 99034 99035 99036 99037 99038 99039 99040 99041 99042 99043 99044 99045 99046 99047 99048 99049 9...
output:
30 5 10 54 56 19 151 50 14 7 6 27 109 11 85 76 84 46 16 29 26 10 120 22 36 16 26 170 31 188 -1180 30 135 41 30 76 151 33 7 32 38 35 73 8 43 16 83 47 205 44 13 29 21 11 140 4 88 5 7 44 41 -1175 30 43 6 62 98 204 20 8 5 85 49 125 1 65 13 66 44 123 16 4 64 20 57 20 39 94 4 6 102 57 -1166 30 167 2 17...
result:
ok correct (1000 test cases)
Test #7:
score: 0
Accepted
time: 211ms
memory: 11900kb
input:
1000 998001 998002 998003 998004 998005 998006 998007 998008 998009 998010 998011 998012 998013 998014 998015 998016 998017 998018 998019 998020 998021 998022 998023 998024 998025 998026 998027 998028 998029 998030 998031 998032 998033 998034 998035 998036 998037 998038 998039 998040 998041 998042 9...
output:
30 45 78 29 17 24 33 210 40 12 57 14 134 99 144 130 20 13 17 81 18 27 10 5 5 107 13 83 20 15 -818 30 1 80 30 112 108 33 2 25 197 13 51 2 8 117 56 7 1 65 57 11 93 26 12 26 21 31 182 15 118 -810 30 44 6 43 47 15 75 8 1 99 102 46 33 187 136 77 38 71 101 15 25 37 5 22 10 52 1 82 29 93 -849 30 70 40 8...
result:
ok correct (1000 test cases)
Test #8:
score: 0
Accepted
time: 174ms
memory: 11132kb
input:
1000 999001 999002 999003 999004 999005 999006 999007 999008 999009 999010 999011 999012 999013 999014 999015 999016 999017 999018 999019 999020 999021 999022 999023 999024 999025 999026 999027 999028 999029 999030 999031 999032 999033 999034 999035 999036 999037 999038 999039 999040 999041 999042 9...
output:
30 139 148 31 59 51 109 11 1 13 135 72 64 50 8 28 7 47 11 5 2 72 93 51 24 31 14 139 5 80 -845 30 30 54 103 9 5 5 21 69 19 50 79 67 44 55 56 138 17 6 153 22 50 1 40 35 4 147 18 163 40 -841 30 67 79 20 62 35 7 61 19 134 116 46 40 3 18 23 30 68 50 38 106 79 89 1 103 76 50 39 29 12 -867 30 76 110 215...
result:
ok correct (1000 test cases)