# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1024563 |
2024-07-16T07:52:48 Z |
우민규(#10936) |
Broken Device 2 (JOI22_device2) |
C++17 |
|
0 ms |
0 KB |
#include "Anna.h"
#include <utility>
#include <vector>
using namespace std;
namespace {
const int BITS = 60;
}
int Declare() { return 3 * BITS; }
pair<vector<int>, vector<int>> Anna(long long a) {
// gather a's bits
vector<int> a_bits;
while (a > 0) {
a_bits.push_back(a % 2);
a /= 2;
}
while (a_bits.size() < BITS) a_bits.push_back(0);
vector<int> u, v;
for (auto bit : a_bits) {
u.push_back(bit);
u.push_back(bit);
u.push_back(bit);
}
v.push_back(0);
while (v.size() < u.size()) v.push_back(!v.back());
return make_pair(u, v);
}
#include "Bruno.h"
#include <utility>
#include <vector>
using namespace std;
namespace {
// const int BITS = 5;
}
long long Bruno(vector<int> u) {
// remove u's elements
// u_red: (value, count)
vector<pair<int, int>> u_red;
int pu = 4;
for (auto u : u) {
if (u == pu) {
if (u_red.empty() || u_red.back().first != u) {
u_red.push_back({u, 1});
} else {
u_red.back().second += 1;
}
}
pu = u;
}
vector<int> a_bits;
for (auto [v, c] : u_red) {
for (int i = 0; i < (c + 2) / 3; ++i) a_bits.push_back(v);
}
int64_t a = 0;
for (int i = a_bits.size() - 1; i >= 0; --i) {
a = 2 * a + a_bits[i];
}
return a;
}
Compilation message
Bruno.cpp: In function 'long long int Bruno(std::vector<int>)':
Bruno.cpp:32:3: error: 'int64_t' was not declared in this scope
32 | int64_t a = 0;
| ^~~~~~~
Bruno.cpp:34:5: error: 'a' was not declared in this scope
34 | a = 2 * a + a_bits[i];
| ^
Bruno.cpp:36:10: error: 'a' was not declared in this scope
36 | return a;
| ^