Submission #730935

# Submission time Handle Problem Language Result Execution time Memory
730935 2023-04-26T16:02:05 Z myrcella Ancient Machine (JOI21_ancient_machine) C++17
100 / 100
68 ms 8856 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 and pos+1<N) {
    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) {
      |    ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 0 ms 520 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 520 KB Output is correct
9 Correct 1 ms 520 KB Output is correct
10 Correct 1 ms 520 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 8272 KB Output is correct
2 Correct 53 ms 8188 KB Output is correct
3 Correct 59 ms 8252 KB Output is correct
4 Correct 51 ms 8224 KB Output is correct
5 Correct 56 ms 8336 KB Output is correct
6 Correct 55 ms 8428 KB Output is correct
7 Correct 52 ms 8300 KB Output is correct
8 Correct 51 ms 8456 KB Output is correct
9 Correct 55 ms 8256 KB Output is correct
10 Correct 61 ms 8312 KB Output is correct
11 Correct 52 ms 8300 KB Output is correct
12 Correct 60 ms 8272 KB Output is correct
13 Correct 64 ms 8736 KB Output is correct
14 Correct 56 ms 8332 KB Output is correct
15 Correct 47 ms 8244 KB Output is correct
16 Correct 51 ms 8384 KB Output is correct
17 Correct 65 ms 8692 KB Output is correct
18 Correct 55 ms 8404 KB Output is correct
19 Correct 59 ms 8440 KB Output is correct
20 Correct 63 ms 8384 KB Output is correct
21 Correct 49 ms 8324 KB Output is correct
22 Correct 55 ms 8752 KB Output is correct
23 Correct 51 ms 8284 KB Output is correct
24 Correct 68 ms 8252 KB Output is correct
25 Correct 61 ms 8300 KB Output is correct
26 Correct 63 ms 8696 KB Output is correct
27 Correct 55 ms 8396 KB Output is correct
28 Correct 55 ms 8856 KB Output is correct
29 Correct 66 ms 8300 KB Output is correct
30 Correct 55 ms 8396 KB Output is correct
31 Correct 54 ms 8396 KB Output is correct
32 Correct 51 ms 8356 KB Output is correct
33 Correct 53 ms 8596 KB Output is correct