QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618630#8790. First Billionucup-team134#TL 58ms4264kbC++171.2kb2024-10-07 00:58:162024-10-07 00:58:17

Judging History

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

  • [2024-10-07 00:58:17]
  • 评测
  • 测评结果:TL
  • 用时:58ms
  • 内存:4264kb
  • [2024-10-07 00:58:16]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128

using namespace std;

mt19937 rng(time(NULL));
const int N=1e9;
double r(){
	return (double)(rng()%N)/N;
}
double p(int ol,int ne,double temp){
	if(ne<ol)return 1.0;
	return exp((ol-ne)/temp);
}

int main()
{
	int n;
	scanf("%i",&n);
	vector<bool> in(n);
	int sm=0;
	vector<int> c(n);
	for(int i=0;i<n;i++){
		scanf("%i",&c[i]);
	}
	for(int i=0;i<n/2;i++){
		int x=rng()%n;
		while(in[x])x=rng()%n;
		in[x]=1;
		sm+=c[x];
	}
	double temp=1e9,an=0.999995;
	int treba=1e9;
	while(1){
		int a=rng()%n;
		while(!in[a])a=rng()%n;
		int b=rng()%n;
		while(in[b])b=rng()%n;
		int ns=sm-c[a]+c[b];
		double x=p(abs(treba-sm),abs(treba-ns),temp);
		if(r()<=x){
			in[a]=0;
			in[b]=1;
			sm=ns;
		}
		if(ns==treba){
			printf("%i",n/2);
			for(int i=0;i<n;i++){
				if(in[i]){
					printf(" %i",i+1);
				}
			}
			printf("\n");
			return 0;
		}
		temp=temp*an;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4256kb

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

5 2 3 4 8 10

result:

ok OK (n = 10)

Test #2:

score: 0
Accepted
time: 0ms
memory: 4120kb

input:

10
119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836

output:

5 2 5 6 8 9

result:

ok OK (n = 10)

Test #3:

score: 0
Accepted
time: 1ms
memory: 4132kb

input:

14
384615281 84612238 83310504 54746763 142296081 56775470 128760350 343006424 177232390 214368720 67220468 21895072 16352717 224807522

output:

7 2 3 4 5 8 11 14

result:

ok OK (n = 14)

Test #4:

score: 0
Accepted
time: 0ms
memory: 4184kb

input:

14
270208635 14270307 89661499 113578022 47687195 101043954 38775146 208193324 650676076 351701957 3427619 59535626 24230888 27009752

output:

7 5 7 8 9 11 13 14

result:

ok OK (n = 14)

Test #5:

score: 0
Accepted
time: 5ms
memory: 3952kb

input:

20
61638928 106712373 5946815 178135484 4937573 111395400 15504655 67139983 101814514 312223647 130341028 43244171 37671364 54108486 337181317 37924824 153793862 70383750 102917244 66984582

output:

10 1 2 3 6 7 15 16 17 19 20

result:

ok OK (n = 20)

Test #6:

score: 0
Accepted
time: 5ms
memory: 4264kb

input:

20
67858098 61231428 99398662 1883806 82465954 303619377 87516412 154956240 94872199 76508350 13276828 136541811 203282099 99160366 127539385 13364660 141176136 39751629 67888657 127707903

output:

10 1 3 4 5 8 11 12 13 14 17

result:

ok OK (n = 20)

Test #7:

score: 0
Accepted
time: 58ms
memory: 4072kb

input:

24
17125795 281143405 10375259 196293002 158174864 34520650 52919232 87393970 99085271 62281508 67168428 55174991 54533464 51393059 89276370 41441658 72793517 30466999 73758332 97064918 111541434 142047546 12934221 101092107

output:

12 3 4 5 10 13 15 17 18 19 20 22 23

result:

ok OK (n = 24)

Test #8:

score: -100
Time Limit Exceeded

input:

24
70224368 148769600 36654748 23404220 15009825 57449487 46896672 6065662 10377031 133719710 23220853 184445684 8462667 88501546 155244839 229323557 140109402 52520271 78995771 75721556 87987586 118427778 107013825 101453342

output:


result: