Submission #1032269

# Submission time Handle Problem Language Result Execution time Memory
1032269 2024-07-23T14:23:54 Z Rafi22 Ancient Machine (JOI21_ancient_machine) C++17
100 / 100
58 ms 8956 KB
#include "Anna.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)

namespace {

	void code(vector<int>V)
	{
		vector<ll>fib(41);
		fib[0]=1;
		fib[1]=2;
		FOR(i,2,40) fib[i]=fib[i-1]+fib[i-2];
		ll x=0;
		ROF(i,39,0) if(V[i]) x+=fib[i];
		FOR(i,0,27)
		{
			if(x&(1<<i)) Send(1);
			else Send(0);
		}
	}
}

void Anna(int n,vector<char>S)
{
	int xd=n;
	FOR(i,0,n-1)
	{
		if(S[i]=='X')
		{
			xd=i;
			break;
		}
	}
	int m=100000;
	vector<int>a(m,0);
	if(xd<n-1)
	{
		a[xd]=1;
		FOR(i,xd+1,n-2) if(S[i]=='Z'&&(i==n-1||S[i+1]!='Z')) a[i+1]=1;
	}
	for(int i=0;i<m;i+=40)
	{
		vector<int>T;
		FOR(j,i,i+39) T.pb(a[j]);
		code(T);
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)

namespace {

}

void Bruno(int n,int l,vector<int>A)
{
	vector<ll>fib(41);
	fib[0]=1;
	fib[1]=2;
	FOR(i,2,40) fib[i]=fib[i-1]+fib[i-2];
	int m=100000;
	vector<int>a(m+1,0);
	int it=0;
	for(int i=0;i<sz(A);i+=28)
	{
		int x=0;
		FOR(j,0,27) if(A[i+j]) x+=(1<<j);
		ROF(j,39,0)
		{
			if(x>=fib[j])
			{
				x-=fib[j];
				a[it+j]=1;
			}
		}
		it+=40;
	}
	a[n]=1;
	int last=-1,k=-1;
	bool xd=0;
	FOR(i,0,n)
	{
		if(a[i])
		{
			if(!xd)
			{
				ROF(j,i,1) Remove(j-1);
				k=i+1;
				last=i+1;
				xd=1;
			}
			else
			{
				ROF(j,i-1,last+1) Remove(j-1);
				Remove(i-1);
				last=i;
			}
		}
	}
	if(k<=n) Remove(k-1);
}

# Verdict Execution time Memory Grader output
1 Correct 8 ms 2864 KB Output is correct
2 Correct 7 ms 3060 KB Output is correct
3 Correct 11 ms 2868 KB Output is correct
4 Correct 7 ms 2868 KB Output is correct
5 Correct 7 ms 2856 KB Output is correct
6 Correct 10 ms 2852 KB Output is correct
7 Correct 9 ms 2860 KB Output is correct
8 Correct 9 ms 2868 KB Output is correct
9 Correct 7 ms 2864 KB Output is correct
10 Correct 9 ms 2864 KB Output is correct
11 Correct 7 ms 3120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 8664 KB Output is correct
2 Correct 30 ms 8544 KB Output is correct
3 Correct 36 ms 8648 KB Output is correct
4 Correct 31 ms 8956 KB Output is correct
5 Correct 30 ms 8488 KB Output is correct
6 Correct 34 ms 8484 KB Output is correct
7 Correct 30 ms 8544 KB Output is correct
8 Correct 28 ms 8520 KB Output is correct
9 Correct 28 ms 8620 KB Output is correct
10 Correct 46 ms 8532 KB Output is correct
11 Correct 37 ms 8492 KB Output is correct
12 Correct 32 ms 8476 KB Output is correct
13 Correct 39 ms 8444 KB Output is correct
14 Correct 40 ms 8356 KB Output is correct
15 Correct 54 ms 8504 KB Output is correct
16 Correct 37 ms 8576 KB Output is correct
17 Correct 39 ms 8440 KB Output is correct
18 Correct 43 ms 8532 KB Output is correct
19 Correct 47 ms 8448 KB Output is correct
20 Correct 33 ms 8492 KB Output is correct
21 Correct 33 ms 8536 KB Output is correct
22 Correct 39 ms 8400 KB Output is correct
23 Correct 34 ms 8492 KB Output is correct
24 Correct 36 ms 8488 KB Output is correct
25 Correct 39 ms 8544 KB Output is correct
26 Correct 58 ms 8476 KB Output is correct
27 Correct 40 ms 8460 KB Output is correct
28 Correct 39 ms 8408 KB Output is correct
29 Correct 39 ms 8544 KB Output is correct
30 Correct 41 ms 8504 KB Output is correct
31 Correct 42 ms 8440 KB Output is correct
32 Correct 33 ms 8548 KB Output is correct
33 Correct 37 ms 8508 KB Output is correct