#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define CNT(x) __builtin_popcountll(x)
#include <bits/stdc++.h>
#include "Anna.h"
const char ch[] = {'X' , 'Y' , 'Z'};
long long pw[50];
void Anna(int N, std::vector<char> S) {
pw[0] = 1;
for(int i=1 ; i<=38 ; ++i) pw[i] = 1LL * pw[i-1] * 3;
for(int i=0 ; i<N ; i+=38)
{
long long tmp = 0;
for(int j=i ; j<=std::min(N-1 , i+37) ; ++j)
{
for(int k=0 ; k<3 ; ++k) if(S[j] == ch[k])
{
tmp += pw[j-i] * k;
}
}
for(int j=0 ; j<=62 ; ++j) Send(BIT(tmp , j));
}
}
#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define CNT(x) __builtin_popcountll(x)
#include <bits/stdc++.h>
#include "Bruno.h"
const char ch[] = {'X' , 'Y' , 'Z'};
long long pw[50];
void Bruno(int N, int L, std::vector<int> A)
{
std::vector<char> s;
for(int i=0 ; i<L ; i+=63)
{
long long tmp = 0;
for(int j=0 ; j<=62 ; ++j)
{
if(A[i+j] == 1) tmp += MASK(j);
}
for(int j=1 ; j<=38 ; ++j)
{
int c = tmp % 3;
tmp /= 3;
s.push_back(ch[c]);
if((int)s.size() == N) break;
}
}
std::stack<int> st;
for(int i=0 ; i<N ; ++i)
{
if(st.size() && s[i] == s[st.top()])
{
Remove(i);
continue;
}
if(s[i] == 'X')
{
st.push(i);
}
else if(s[i] == 'Y')
{
if(st.size()) st.push(i);
else Remove(i);
}
else
{
if((int)st.size() < 2)
{
Remove(i);
continue;
}
if(st.size() && s[st.top()] == 'X')
{
Remove(st.top());
st.pop();
}
while((int)st.size() > 2)
{
Remove(st.top());
st.pop();
Remove(st.top());
st.pop();
}
if((int)st.size() == 2)
{
Remove(st.top());
st.pop();
}
Remove(i);
}
}
while(st.size()) Remove(st.top()) , st.pop();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
520 KB |
Output is correct |
4 |
Correct |
1 ms |
520 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
0 ms |
520 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
612 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
520 KB |
Output is correct |
11 |
Correct |
1 ms |
612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
63 ms |
9104 KB |
Partially correct |
2 |
Partially correct |
64 ms |
9100 KB |
Partially correct |
3 |
Partially correct |
69 ms |
9040 KB |
Partially correct |
4 |
Partially correct |
87 ms |
9132 KB |
Partially correct |
5 |
Partially correct |
62 ms |
9112 KB |
Partially correct |
6 |
Partially correct |
66 ms |
9128 KB |
Partially correct |
7 |
Partially correct |
71 ms |
9104 KB |
Partially correct |
8 |
Partially correct |
70 ms |
9112 KB |
Partially correct |
9 |
Partially correct |
70 ms |
9108 KB |
Partially correct |
10 |
Partially correct |
64 ms |
9176 KB |
Partially correct |
11 |
Partially correct |
69 ms |
9060 KB |
Partially correct |
12 |
Partially correct |
68 ms |
9044 KB |
Partially correct |
13 |
Partially correct |
64 ms |
9008 KB |
Partially correct |
14 |
Partially correct |
71 ms |
9140 KB |
Partially correct |
15 |
Partially correct |
75 ms |
9020 KB |
Partially correct |
16 |
Partially correct |
75 ms |
9028 KB |
Partially correct |
17 |
Partially correct |
68 ms |
9048 KB |
Partially correct |
18 |
Partially correct |
72 ms |
9040 KB |
Partially correct |
19 |
Partially correct |
78 ms |
9000 KB |
Partially correct |
20 |
Partially correct |
65 ms |
8972 KB |
Partially correct |
21 |
Partially correct |
62 ms |
9140 KB |
Partially correct |
22 |
Partially correct |
81 ms |
9104 KB |
Partially correct |
23 |
Partially correct |
66 ms |
9116 KB |
Partially correct |
24 |
Partially correct |
64 ms |
9084 KB |
Partially correct |
25 |
Partially correct |
68 ms |
9100 KB |
Partially correct |
26 |
Partially correct |
73 ms |
8972 KB |
Partially correct |
27 |
Partially correct |
80 ms |
8960 KB |
Partially correct |
28 |
Partially correct |
69 ms |
9096 KB |
Partially correct |
29 |
Partially correct |
83 ms |
8952 KB |
Partially correct |
30 |
Partially correct |
76 ms |
9080 KB |
Partially correct |
31 |
Partially correct |
68 ms |
9032 KB |
Partially correct |
32 |
Partially correct |
68 ms |
9116 KB |
Partially correct |
33 |
Partially correct |
64 ms |
9040 KB |
Partially correct |