QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#329105#1840. K-onstructionucup-team1004AC ✓220ms10200kbC++141.5kb2024-02-16 13:30:142024-02-16 13:30:14

Judging History

你现在查看的是最新测评结果

  • [2024-02-16 13:30:14]
  • 评测
  • 测评结果:AC
  • 用时:220ms
  • 内存:10200kb
  • [2024-02-16 13:30:14]
  • 提交

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;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 7284kb

input:

2
3
16

output:

30
19 75 15 25 15 49 10 29 67 90 72 14 18 16 29 20 143 43 36 86 99 16 75 14 123 59 8 84 151 -1486 
30
28 43 2 30 2 38 20 52 15 43 72 51 8 38 16 38 52 103 13 49 24 193 53 41 13 123 44 285 11 -1460 

result:

ok correct (2 test cases)

Test #2:

score: 0
Accepted
time: 3ms
memory: 9608kb

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
19 75 15 25 15 49 10 29 67 90 72 14 18 16 29 20 143 43 36 86 99 16 75 14 123 59 8 84 151 -1499 
30
19 75 15 25 15 49 10 29 67 90 72 14 18 16 29 20 143 43 36 86 99 16 75 14 123 59 8 84 151 -1500 
30
19 75 15 25 15 49 10 29 67 90 72 14 18 16 29 20 143 43 36 86 99 16 75 14 123 59 8 84 151 -1486 
30
...

result:

ok correct (1000 test cases)

Test #3:

score: 0
Accepted
time: 10ms
memory: 10024kb

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
19 12 15 9 1 104 4 25 58 40 241 47 177 39 12 24 41 2 41 78 205 3 28 11 88 67 5 81 23 -1414 
30
40 22 6 68 149 7 3 66 20 57 16 41 28 35 45 66 28 132 98 21 181 7 186 35 18 34 25 14 52 -1381 
30
215 11 73 11 1 84 129 3 4 32 1 67 10 19 3 53 10 8 18 107 124 9 80 20 59 74 100 162 13 -1424 
30
37 27 136...

result:

ok correct (1000 test cases)

Test #4:

score: 0
Accepted
time: 220ms
memory: 9868kb

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
132 99 118 8 28 63 6 241 16 1 32 24 75 9 5 49 3 61 123 54 32 145 64 13 61 11 5 7 15 -753 
30
38 4 103 90 36 28 28 48 41 55 25 5 62 79 47 69 46 13 11 1 99 207 10 140 1 67 5 101 41 -882 
30
123 82 33 40 55 5 42 31 41 7 8 56 153 16 16 36 185 5 16 37 44 5 225 58 23 37 28 16 77 -811 
30
14 47 30 47 29...

result:

ok correct (1000 test cases)

Test #5:

score: 0
Accepted
time: 25ms
memory: 9916kb

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
91 26 130 10 170 23 6 16 3 66 19 81 61 80 56 93 2 29 19 34 14 201 7 3 44 97 27 36 56 -1313 
30
119 11 193 71 74 3 44 51 16 34 95 2 6 134 80 8 9 11 30 94 59 8 143 19 18 42 23 26 77 -1312 
30
46 37 126 16 9 56 115 32 11 22 61 47 52 82 150 34 67 160 67 27 58 29 63 24 7 8 71 3 20 -1281 
30
48 118 199...

result:

ok correct (1000 test cases)

Test #6:

score: 0
Accepted
time: 191ms
memory: 9916kb

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
38 14 15 107 39 47 42 104 11 5 100 46 15 15 82 23 14 53 291 85 79 25 26 20 80 49 39 8 28 -1182 
30
48 20 10 139 20 87 19 44 22 92 52 44 6 34 67 41 7 10 50 20 46 92 94 10 42 20 186 19 159 -1164 
30
87 24 134 27 6 3 72 66 12 59 12 8 10 19 31 172 123 66 18 123 55 25 28 7 39 115 1 127 31 -1169 
30
12...

result:

ok correct (1000 test cases)

Test #7:

score: 0
Accepted
time: 213ms
memory: 10200kb

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
31 19 50 32 15 54 158 41 125 99 5 22 56 116 27 42 129 12 23 28 11 11 34 242 19 18 5 29 47 -776 
30
103 24 161 9 16 179 125 28 8 83 31 2 7 107 18 11 43 36 161 5 18 16 21 13 18 97 72 68 20 -817 
30
34 7 42 23 192 119 1 24 51 15 10 16 114 82 23 1 30 107 11 22 2 154 15 53 175 100 46 28 3 -802 
30
50 ...

result:

ok correct (1000 test cases)

Test #8:

score: 0
Accepted
time: 199ms
memory: 9948kb

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
12 134 1 2 119 26 84 77 32 9 218 109 6 31 16 31 48 74 14 6 21 36 2 72 30 8 166 82 34 -800 
30
102 4 106 63 68 77 96 45 82 40 29 96 3 39 9 5 49 95 6 62 5 13 22 1 80 48 55 196 4 -848 
30
83 13 5 118 42 36 103 207 4 41 13 25 23 45 27 37 46 79 200 26 22 16 31 8 57 17 100 61 15 -815 
30
18 10 101 27 2...

result:

ok correct (1000 test cases)