Submission #1256294

#TimeUsernameProblemLanguageResultExecution timeMemory
1256294PenguinsAreCuteHack (APIO25_hack)C++20
100 / 100
68 ms964 KiB
#include "hack.h"
#include <bits/stdc++.h>
using namespace std;
int hack(){
	int n = 0;
	int l = 0, h = 5e8;
	while(h - l > 1) {
		int m = (l + h) / 2;
		long long squirt = 1;
		while(squirt * squirt < (m - l))
			squirt++;
		vector<long long> v = {1};
		for(int j=0;j<squirt-1;j++)
			v.push_back(1LL << 30);
		v.push_back((2LL * l + 1) << 29);
		for(int j=0;j<((m-l)-1)/squirt;j++)
			v.push_back(squirt << 30);
		for(int j=1;j<int(v.size());j++)
			v[j] += v[j-1];
		end(v)[-1] = 1 + ((2LL * m - 1) << 29);
		(collisions(v)?h:l) = m;
	}
	n = 2 * l + 1;
	while(!collisions({1,n+1}))
		n <<= 1;
	return n;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...