#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define FORD(i, n) for(int i = n - 1; i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "skycrapers"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
void Anna(int N, std::vector<char> S);
void Send(int a);
void Anna(int n, vector<char> S)
{
rep(i, n) if(S[i - 1] == 'X')
{
Send(0);
Send(0);
}
else if(S[i - 1] == 'Y')
{
Send(0);
Send(1);
}
else if(S[i - 1] == 'Z')
{
Send(1);
Send(0);
}
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define FORD(i, n) for(int i = n - 1; i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "skycrapers"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
void Bruno(int N, int L, std::vector<int> A);
void Remove(int d);
void Bruno(int n, int Len, vector<int> A)
{
vector<int> a(n);
FOR(i, n)
{
a[i] = 0;
a[i] |= A[i << 1 | 1];
a[i] |= 1 << A[i << 1];
}
int L = 0, R = n - 1;
while(L < n && a[L] != 0) ++L;
while(R >= 0 && a[R] != 2) --R;
if(L == n || R < 0 || L > R)
{
FOR(i, n) Remove(i);
return;
}
forn(i, 0, L - 1) Remove(i);
forn(i, R + 1, n - 1) Remove(i);
vector<int> pos_y;
vector<int> pos_x;
pos_x.pb(L);
++L;
while(L <= R && a[L] != 1) Remove(L), ++L;
for(int i = L; i <= R; ++i)
{
int j = i;
while(j <= R)
{
if(a[i] == a[j] || 2 - a[i] == a[j])
++j;
else break;
}
--j;
forn(k, i, j - 1) Remove(k);
if(a[j] != 1)
{
if(a[j] == 2)
{
if(j != R)
{
Remove(pos_y.back());
pos_y.pop_back();
Remove(j);
}
else
{
while(sz(pos_y) && sz(pos_x))
{
Remove(pos_y.back()); pos_y.pop_back();
Remove(pos_x.back()); pos_x.pop_back();
}
}
} else pos_x.pb(j);
} else pos_y.pb(j);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
780 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
9624 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |