#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
69 ms |
2556 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
5916 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |