#include "Anna.h"
#include <vector>
#include "bits/stdc++.h"
using namespace std;
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
variable_example++;
for(int i=0; i<N; i+=10) {
int ans = 0;
for(int j=i; j<min(N, i+10); j++) {
ans *= 3;
ans += (S[j] == 'X' ? 0 : (S[j] == 'Y' ? 1 : 2));
}
for(int j=0; j<16; j++) {
if(ans & (1<<j)) Send(1);
else Send(0);
}
}
}
/*
g++ -std=gnu++17 -O2 -fsigned-char -o grader grader.cpp Anna.cpp Bruno.cpp
./grader < input.txt
*/
#include "Bruno.h"
#include <vector>
#include "bits/stdc++.h"
using namespace std;
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
string S;
int j = 0;
for(int i=0; i<L; i+=16) {
int rem = min(10, N - j);
j += 10;
int base = pow(3, rem - 1);
int ans = 0;
for(int j=i; j<min(L, i+16); j++) {
if(A[j] == 1) ans += (1 << (j-i));
}
for(int j=rem-1; j>=0; j--) {
int div = ans / base;
ans %= base;
base /= 3;
if(div == 0) S += 'X';
else if(div == 1) S += 'Y';
else S += 'Z';
}
}
int lb = -1, rb = -1;
for(int i=0; i<N; i++) {
if(S[i] == 'X') {
lb = i; break;
}
}
for(int i=N-1; i>=0; i--) {
if(S[i] == 'Z') {
rb = i; break;
}
}
if(lb == -1 || rb == -1) {
for(int i=0; i<N; i++) Remove(i);
return;
}
for(int i=0; i<lb; i++) Remove(i);
for(int i=rb+1; i<N; i++) Remove(i);
vector<int> seq;
for(int i=lb; i<=rb; i++) {
if(i == lb || i == rb) seq.push_back(i);
else if(S[i] == 'Y' && S[i-1] == 'Y') Remove(i);
else if(S[i] == 'Y') seq.push_back(i);
else if(S[i-1] == 'Y') seq.push_back(i);
else Remove(i);
}
vector<int> seq2;
seq2.push_back(seq[0]);
for(int i=1; i<seq.size(); i++) {
seq2.push_back(seq[i]);
if(S[seq[i-1]] != 'Y' && S[seq[i]] != 'Y') {
if(i == 1) {
Remove(seq[i]);
seq2.pop_back();
}
else {
Remove(seq[i-1]);
seq2.pop_back();
seq2.pop_back();
seq2.push_back(seq[i]);
}
}
}
seq = seq2; // remainder
vector<int> stk;
for(int i=0; i<seq.size(); i++) {
stk.push_back(seq[i]);
while(stk.size() >= 3 && S[stk[stk.size() - 3]] == 'X' && S[stk[stk.size() - 2]] == 'Y' && S[stk.back()] == 'Z') {
Remove(stk[stk.size() - 2]);
int tp = stk.back();
stk.pop_back();
stk.pop_back();
if(stk.back() > 0) {
int cur = stk.back();
Remove(cur);
stk.pop_back();
stk.push_back(tp);
}
else Remove(tp);
}
}
for(int X: stk) Remove(X);
}
/*
g++ -std=gnu++17 -O2 -fsigned-char -o grader grader.cpp Anna.cpp Bruno.cpp
./grader < input.txt
*/
Compilation message
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:62:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | for(int i=1; i<seq.size(); i++) {
| ~^~~~~~~~~~~
Bruno.cpp:79:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for(int i=0; i<seq.size(); i++) {
| ~^~~~~~~~~~~
Bruno.cpp: At global scope:
Bruno.cpp:10:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
10 | int FunctionExample(int P) { return 1 - P; }
| ^~~~~~~~~~~~~~~
Bruno.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
8 | int variable_example = 0;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
780 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
57 ms |
9480 KB |
Partially correct |
2 |
Incorrect |
57 ms |
9384 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |