답안 #417457

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417457 2021-06-03T18:04:56 Z errorgorn Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
70 ms 8932 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]);
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:62:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   62 |  for (auto &it:bits) cout<<it<<" "; cout<<endl;
      |  ^~~
Bruno.cpp:62:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   62 |  for (auto &it:bits) cout<<it<<" "; cout<<endl;
      |                                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 488 KB Do not print anything to standard output!!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 8932 KB Do not print anything to standard output!!
2 Halted 0 ms 0 KB -