Submission #1008519

# Submission time Handle Problem Language Result Execution time Memory
1008519 2024-06-26T13:59:41 Z Math4Life2020 Magic Show (APIO24_show) C++17
0 / 100
4 ms 812 KB
// Source: https://usaco.guide/general/io
 
#include <bits/stdc++.h>
#include "Alice.h"
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
ll N = 5000;
 
ld seed0 = 0.1434;
ld seed = seed0;
ld getseed() {
	seed = 3.67*seed*(1.0-seed);
	return seed;
}
 
ll getrng(ll x) { //random integer in [0,x-1]
	return (((ll) round(10000000000*getseed()))%x);
}
 
ll l2(ll x) {
	return (31-__builtin_clz(x));
}
 
/*ll setN(int Q) {
	return 143414341434143469;
}*/
 
void rngreset() {
	seed=seed0;
}
 
vector<pii> Alice() {
	ll X = setN((int) N);
	vector<pii> vout;
	vector<bool> xv;
	ll E = 60;
	for (ll e=59;e>=0;e--) {
		xv.push_back((X>>e)%2);
	}
	for (ll n=1;n<N;n++) {
		ll D = l2(n)-1;
		ll val = 0;
		for (ll d=0;d<D;d++) {
			ll e = getrng(E);
			val += xv[e]*(1LL<<d);
		}
		vout.push_back({val+1,n+1});
	}
	rngreset();
	return vout;
}
 
long long Bob(vector<pii> V) {
	ll vals[N];
	for (ll i=0;i<N;i++) {
		vals[i]=-1;
	}
	for (pii p0: V) {
		vals[p0.second-1]=p0.first-1;
	}
	vector<ll> xv;
	ll E = 60;
	for (ll e=59;e>=0;e--) {
		xv.push_back(-1);
	}
	for (ll n=1;n<N;n++) {
		ll D = l2(n)-1;
		for (ll d=0;d<D;d++) {
			ll e = getrng(E);
			//val += xv[e]*(1LL<<d);
			if (vals[n]!=-1) {
				xv[e]=(vals[n]>>d)%2;
			}
		}
	}
	ll X = 0;
	for (ll e=0;e<E;e++) {
		X += xv[e]*(1LL<<(E-1-e));
	}
    rngreset();
	return X;
}
 
/*int main() {
	vector<pii> A0 = Alice();
	vector<pii> A1;
	ld seed2=0.192847135;
	for (pii p0: A0) {
		ll b0 = ((ll) round(1000000*seed2))%10;
		seed2=3.61*seed2*(1.000000-seed2);
		if (b0==0) {
			A1.push_back(p0);
		}
	}
	cout << Bob(A1);
}*/
// Source: https://usaco.guide/general/io
 
#include <bits/stdc++.h>
#include "Bob.h"
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
ll N = 5000;
 
ld seed0 = 0.1434;
ld seed = seed0;
ld getseed() {
	seed = 3.67*seed*(1.0-seed);
	return seed;
}
 
ll getrng(ll x) { //random integer in [0,x-1]
	return (((ll) round(10000000000*getseed()))%x);
}
 
ll l2(ll x) {
	return (31-__builtin_clz(x));
}
 
/*ll setN(int Q) {
	return 143414341434143469;
}*/
 
void rngreset() {
	seed=seed0;
}
 
long long Bob(vector<pii> V) {
	ll vals[N];
	for (ll i=0;i<N;i++) {
		vals[i]=-1;
	}
	for (pii p0: V) {
		vals[p0.second-1]=p0.first-1;
	}
	vector<ll> xv;
	ll E = 60;
	for (ll e=59;e>=0;e--) {
		xv.push_back(-1);
	}
	for (ll n=1;n<N;n++) {
		ll D = l2(n)-1;
		for (ll d=0;d<D;d++) {
			ll e = getrng(E);
			//val += xv[e]*(1LL<<d);
			if (vals[n]!=-1) {
				xv[e]=(vals[n]>>d)%2;
			}
		}
	}
	ll X = 0;
	for (ll e=0;e<E;e++) {
		X += xv[e]*(1LL<<(E-1-e));
	}
    rngreset();
	return X;
}
 
/*int main() {
	vector<pii> A0 = Alice();
	vector<pii> A1;
	ld seed2=0.192847135;
	for (pii p0: A0) {
		ll b0 = ((ll) round(1000000*seed2))%10;
		seed2=3.61*seed2*(1.000000-seed2);
		if (b0==0) {
			A1.push_back(p0);
		}
	}
	cout << Bob(A1);
}*/
# Verdict Execution time Memory Grader output
1 Correct 4 ms 808 KB Correct.
2 Correct 4 ms 812 KB Correct.
3 Incorrect 3 ms 808 KB Incorrect answer.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 808 KB Correct.
2 Correct 4 ms 812 KB Correct.
3 Incorrect 3 ms 808 KB Incorrect answer.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 808 KB Correct.
2 Correct 4 ms 812 KB Correct.
3 Incorrect 3 ms 808 KB Incorrect answer.
4 Halted 0 ms 0 KB -