Submission #547598

#TimeUsernameProblemLanguageResultExecution timeMemory
547598flashhhAncient Machine (JOI21_ancient_machine)C++17
0 / 100
69 ms5916 KiB
#include <bits/stdc++.h> #include "Anna.h" using namespace std; void send(char x) { if (x == 'X') { Send(0); Send(0); } else if (x == 'Y') { Send(0); Send(1); } else { Send(1); Send(0); } } void Anna(int n,vector<char> s) { for (int i=0;i<n;++i) send(s[i]); }
#include <bits/stdc++.h> #include "Bruno.h" #define N 100005 #define pii pair<int,int> #define fi first #define se second #define pb emplace_back #define getbit(x,y) (((x)>>(y))&1) #define getoff(x,y) ((x)^(1<<(y))) using namespace std; int n,l,dp[1<<18],trace[1<<18]; char a[N]; vector<int> s; int dq(int mask) { if (mask == 0) return 0; if (dp[mask] != -1) return dp[mask]; vector<int> vt; for (int i=1;i<=n;++i) if (getbit(mask,i-1)) vt.pb(i); int ans = 0; for (int e=0;e<(int)vt.size();++e) { bool ok1 = 0; bool ok2 = 0; bool ok3 = 0; if (e > 0 && a[vt[e-1]] == 'X') ok1 = 1; if (a[vt[e]] == 'Y') ok2 = 1; if (e+1 < (int)vt.size() && a[vt[e+1]] == 'Z') ok3 = 1; int kq = dq(getoff(mask, vt[e]-1)) + (ok1&ok2&ok3); if (ans <= kq) { ans = kq; trace[mask] = vt[e]; } } return dp[mask] = ans; } void dq2(int mask) { if (mask == 0) return; Remove(trace[mask]); dq2(getoff(mask,trace[mask]-1)); } void Bruno(int n1,int l1,vector<int> s1) { n = n1; l = l1; s = s1; for (int i=0;i<n;++i) if (s[i<<1] == 0) { if (s[i<<1|1] == 0) a[i+1] = 'X'; else a[i+1] = 'Y'; } else a[i+1] = 'Z'; memset(dp,-1,sizeof(dp)); dq((1<<n)-1); dq2((1<<n)-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...