답안 #730931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730931 2023-04-26T15:55:31 Z myrcella Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
91 ms 8772 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

#include "Anna.h"

void Anna(int N, std::vector<char> S) {
	bool ok = false;
	vector <int> tmp;
	ll dp[63];
	rep(i,0,N) {
		if (ok==false) {
			if (S[i]=='X') tmp.pb(1),tmp.pb(0),ok=true;
			else tmp.pb(0);
		}
		else if (tmp.back()!=1 and S[i]=='Z' and (i+1==N or S[i+1]!='Z')) tmp.pb(1);
		else tmp.pb(0);
 	}
	while (SZ(tmp)%63!=0) tmp.pb(0);
	dp[0] = 1;
	dp[1] = 2;
	rep(i,2,63) dp[i] = dp[i-1] + dp[i-2];
	int cur = 0;
  N++;
	while (cur<N) {
		ll cnt = 0;
		rep(i,cur,cur+63) {
			if (tmp[i]==1) cnt += dp[cur+63-i-1];
		}
		rep(j,0,44) Send(((cnt>>j)&1));
		cur += 63;
	}
	return;
}
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

#include "Bruno.h"

void Bruno(int N, int L, std::vector<int> A) {
	vector <int> tmp;
	ll dp[63];
	dp[0] = 1;
	dp[1] = 2;
	rep(i,2,63) dp[i] = dp[i-1] + dp[i-2];
	int cur = 0;
	while (cur<L) {
		ll cnt = 0;
		rep(i,cur,cur+44) if (A[i]) cnt += (1ll<<(i-cur));
		rep(j,0,63) {
			if (cnt>=dp[63-j-1]) {
				tmp.pb(1);
				cnt -= dp[63-j-1];
			} 
			else tmp.pb(0);
		}
		cur += 44;
	}
	bool ok = false;
	int pos = -1;
	vector <int> hi;
	rep(i,0,N) {
		if (ok==false) {
			if (tmp[i]==1) pos = i,ok=true;
			else Remove(i);
		}
		else {
          if (i==pos+1) continue;
			if (tmp[i]==1) {
				while (!hi.empty()) Remove(hi.back()-1),hi.pop_back();
				Remove(i-1);
			}
			else hi.pb(i);
		}
	}
  if (ok) {
    if (tmp[N]==1) {
				while (!hi.empty()) Remove(hi.back()-1),hi.pop_back();
				Remove(N-1);
			}
			else hi.pb(N);
  }
	while (!hi.empty()) Remove(hi.back()-1),hi.pop_back();
	if (pos!=-1) Remove(pos);
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:54:11: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   54 |           if (i==pos+1) continue;
      |           ^~
Bruno.cpp:55:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   55 |    if (tmp[i]==1) {
      |    ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 516 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 0 ms 508 KB Output is correct
4 Correct 0 ms 508 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 1 ms 520 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Incorrect 0 ms 516 KB Wrong Answer [4]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 8044 KB Output is correct
2 Correct 64 ms 8152 KB Output is correct
3 Correct 57 ms 8000 KB Output is correct
4 Correct 56 ms 8320 KB Output is correct
5 Correct 57 ms 8336 KB Output is correct
6 Correct 69 ms 8432 KB Output is correct
7 Correct 60 ms 8400 KB Output is correct
8 Correct 60 ms 8448 KB Output is correct
9 Correct 55 ms 8396 KB Output is correct
10 Correct 52 ms 8356 KB Output is correct
11 Correct 84 ms 8404 KB Output is correct
12 Correct 59 ms 8296 KB Output is correct
13 Correct 65 ms 8772 KB Output is correct
14 Correct 63 ms 8328 KB Output is correct
15 Correct 54 ms 8512 KB Output is correct
16 Correct 51 ms 8296 KB Output is correct
17 Correct 57 ms 8712 KB Output is correct
18 Correct 65 ms 8296 KB Output is correct
19 Correct 91 ms 8344 KB Output is correct
20 Correct 51 ms 8360 KB Output is correct
21 Correct 49 ms 8300 KB Output is correct
22 Correct 60 ms 8700 KB Output is correct
23 Correct 48 ms 8388 KB Output is correct
24 Correct 53 ms 8456 KB Output is correct
25 Correct 76 ms 8340 KB Output is correct
26 Correct 63 ms 8732 KB Output is correct
27 Incorrect 58 ms 8284 KB Wrong Answer [4]
28 Halted 0 ms 0 KB -