Submission #417460

# Submission time Handle Problem Language Result Execution time Memory
417460 2021-06-03T18:13:30 Z errorgorn Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
58 ms 8740 KB
#include "Anna.h"

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

namespace {
	int n;
	string s;
	
	const int L=44;
	const int B=63;
	
	ll fibo[64];
}

void Anna(int N, std::vector<char> S) {
	fibo[0]=1,fibo[1]=2;
	rep(x,2,64) fibo[x]=fibo[x-2]+fibo[x-1];
	
	n=N;
	rep(x,0,n) s+=S[x];
	
	int pos=0;
	rep(x,0,n) if (s[x]=='X'){
		pos=x;
		break;
	}
	
	rep(x,0,17){
		if (pos&1) Send(1);
		else Send(0);
		pos>>=1;
	}
	
	vector<int> v;
	
	rep(x,0,n){
		if (s[x]=='Z'){
			if (!v.empty() && v.back()==1) v.back()=0;
			v.pub(1);
		}
		else{
			v.pub(0);
		}
	}
	
	while (sz(v)%B) v.pub(0);
	
	while (!v.empty()){
		ll curr=0;
		rep(x,0,B){
			if (v.back()==1) curr+=fibo[x];
			
			v.pob();
		}
		
		rep(x,0,L){
			if (curr&1) Send(1);
			else Send(0);
			
			curr>>=1;
		}
	}
}
#include "Bruno.h"

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

namespace {
	int n,l;
	vector<int> a;
	string s;
	
	const int L=44;
	const int B=63;
	
	ll fibo[64];
	
	vector<int> bits;
}  // namespace

void Bruno(int N, int LL, std::vector<int> A) {
	fibo[0]=1,fibo[1]=2;
	rep(x,2,64) fibo[x]=fibo[x-2]+fibo[x-1];
	
	n=N,l=LL,a=A;
	
	int pos=0;
	rep(x,0,17) pos+=a[x]*(1<<x);
	
	for (int x=17;x<l;x+=L){
		ll curr=0;
		rep(y,0,L){
			curr+=a[x+y]*(1LL<<y);
		}
		
		rep(y,B,0){
			if (curr>=fibo[y]){
				curr-=fibo[y];
				bits.pub(1);
			}
			else{
				bits.pub(0);
			}
		}
	}
	
	//for (auto &it:bits) cout<<it<<" "; cout<<endl;
	
	vector<int> stk;
	rep(x,0,pos+1) stk.pub(x);
	rep(x,pos+1,n){
		if (bits[x]){
			while (stk.back()!=pos){
				Remove(stk.back());
				stk.pob();
			}
			Remove(x);
		}
		else{
			stk.pub(x);
		}
	}
	
	rep(x,0,sz(stk)) Remove(stk[x]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 484 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 1 ms 484 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 0 ms 492 KB Output is correct
6 Correct 0 ms 480 KB Output is correct
7 Correct 0 ms 484 KB Output is correct
8 Correct 0 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 0 ms 484 KB Output is correct
11 Correct 0 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 8740 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -