QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#132254#5177. 摩斯电码 2.0xuqin0 16ms5104kbC++141.7kb2023-07-29 11:22:082023-07-29 11:22:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-29 11:22:10]
  • 评测
  • 测评结果:0
  • 用时:16ms
  • 内存:5104kb
  • [2023-07-29 11:22:08]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<random>
#include<chrono>
#include<bitset>
#include<queue>
#include<cstdlib>
#include<cmath>

using namespace std;
const int maxn=1e5+10, inf=1e9, P=1e9+7;
const double eps=1e-10;
typedef long long LL;
typedef unsigned long long ULL;
const LL INF=4e18;
typedef pair<LL, int> pli;
typedef pair<int, int> pii;
inline int read() {
	int x=0, f=1; char c=getchar();
	for(; c<'0'||c>'9'; c=getchar()) if(c=='-') f=0;
	for(; c>='0'&&c<='9'; c=getchar()) x=x*10+c-'0';
	return f?x:-x;
}
mt19937 rnd((unsigned)chrono::steady_clock::now().time_since_epoch().count());

int n, m, a[maxn], v[maxn], cho[maxn];
LL b[maxn];

int calc(LL b[]) {
	int l=0, r=m;
	while(l<r) {
		int mid=(l+r+1)>>1;
		//can 1  get mid
		LL oth=0;
		for(int i=2; i<=n; ++i) {
			//how many x: b[i]/x > b[1]/mid
			//b[i]*mid/b[1] > x
			oth+=(1LL*b[i]*mid+b[1]-1)/b[1]-1;
			if(oth>1LL*m) break;
		}
		if(oth+mid<=1LL*m) l=mid; else r=mid-1;
	}
	return l;
}

int main() {
	int st=clock();
	n=read(), m=read();
	for(int i=1; i<=n; ++i) v[i]=read();
	for(int i=1; i<=n; ++i) a[i]=read();
	
	for(int i=1; i<n; ++i) b[i]=a[i]+v[i], cho[i]=0; b[n]=v[n]; b[1]+=a[n]; cho[n]=1;
	int ans=calc(b);
	double T=10.0;
	while(clock()-st<900) {
		int x=rnd()%n+1;
		b[(x+cho[x]-1)%n+1]-=a[x];
		b[(x+(cho[x]^1)-1)%n+1]+=a[x];
		int nxt=calc(b);
		if(nxt>=ans) {ans=nxt; cho[x]^=1;}
			else {
				int t=rnd()%100001;
				if(t/100000.0<exp(-(1.0*ans-nxt)/T)) {
					ans=nxt, cho[x]^=1;
				} else {
					b[(x+cho[x]-1)%n+1]+=a[x];
					b[(x+(cho[x]^1)-1)%n+1]-=a[x];
				}
			}
		T*=0.999;
	}
	printf("%d", ans);
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3356kb

input:

5 5
2 5 5 4 3
2 4 4 5 5

output:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 3412kb

input:

5 38
170 62 7 129 93
39 98 2 178 110

output:

14

result:

wrong answer 1st lines differ - expected: '15', found: '14'

Subtask #3:

score: 0
Wrong Answer

Test #9:

score: 20
Accepted
time: 2ms
memory: 3184kb

input:

50 340
145945353 943649879 103681368 412537460 249168929 368424447 732376003 185334999 144319344 511521494 159409847 131972188 193314434 725004712 439570846 364294834 362411427 314220847 829136416 305293003 505373341 638710304 851245152 521859350 644327541 974583375 738591681 147795709 922157319 421...

output:

1

result:

ok single line: '1'

Test #10:

score: -20
Wrong Answer
time: 0ms
memory: 3356kb

input:

50 4
812930736 95702098 665441738 221300735 907249385 493535187 564488639 395538786 904638787 889168971 900357003 21636011 764504998 243769369 89695414 656445453 745884937 656421159 296885639 206987195 368396912 54679316 346974906 192974419 56304682 420269636 396600899 473826419 708845531 57105109 5...

output:

0

result:

wrong answer 1st lines differ - expected: '2', found: '0'

Subtask #4:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 2ms
memory: 3136kb

input:

1000 1000
1000000000 732930495 57470406 998674942 980507254 200197125 826994891 726235561 146440304 908089621 108786784 22006340 629816450 656110319 505896602 620885446 857656443 30603288 902307001 946990065 915078227 237356805 675986931 241912445 489230924 199892606 129509547 544771174 171477200 39...

output:

4

result:

wrong answer 1st lines differ - expected: '5', found: '4'

Subtask #5:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 2ms
memory: 3340kb

input:

10000 1000000000
1000000000 9322 8270 4220 4967 6470 2768 7780 590 1436 4219 7804 8549 8916 9250 1420 5911 2115 7098 9942 4217 7430 5121 4217 395 1363 1098 3314 2058 6689 3270 6734 6663 2769 7773 5406 5705 1208 4409 6282 5593 7665 1334 6208 1138 6856 4597 2152 3666 5645 6841 1182 8469 1768 9165 4521...

output:

952509298

result:

wrong answer 1st lines differ - expected: '952514052', found: '952509298'

Subtask #6:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 16ms
memory: 5104kb

input:

100000 1000000000
1000000000 34788 73380 66152 92356 82130 69036 96709 88944 26043 93630 93922 79818 18546 43338 40621 46994 77235 61925 24567 63929 22345 8049 40400 68808 79834 10769 68961 415 75455 73445 65121 66981 39924 45321 66260 43977 81382 98200 6894 11936 10781 29304 45584 12022 26163 73225...

output:

166617327

result:

wrong answer 1st lines differ - expected: '166625645', found: '166617327'