QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#482837 | #3098. Ancient Machine | nhuang685 | 5 | 30ms | 9684kb | C++20 | 2.8kb | 2024-07-17 22:26:43 | 2024-07-17 22:26:43 |
Judging History
Anna
#include "Anna.h"
#include <bits/stdc++.h>
namespace {
constexpr int LG = 63;
constexpr int SZ = 44;
std::vector<std::array<int64_t, 2>> dp;
void init() {
dp.resize(LG + 1);
dp[1][0] = 1;
dp[1][1] = 1;
for (int i = 2; i <= LG; ++i) {
dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
dp[i][1] = dp[i - 1][0];
}
}
} // namespace
void Anna(int N, std::vector<char> S) {
const int n = N;
std::string s(S.begin(), S.end());
init();
s.resize((n + LG - 1) / LG * LG, 'W');
int st = -1;
bool b = false;
for (int i = 0; i < std::ssize(s); i += LG) {
int64_t val = 0;
for (int j = 0; j < LG; ++j) {
if (s[i + j] == 'X' && st == -1) {
val |= int64_t{1} << j;
st = i + j;
} else if (st != -1 && s[i + j] == 'Z' &&
(i + j == std::ssize(s) - 1 || s[i + j + 1] != 'Z')) {
if (st == i + j - 1) {
b = true;
} else {
val |= int64_t{1} << j;
}
}
}
int64_t num = 0;
for (int j = LG - 1; j >= 0; --j) {
if (((int64_t{1} << j) & val) != 0) {
num += dp[j + 1][0];
}
}
std::cerr << std::bitset<6>(val) << '\n';
for (int j = 0; j < SZ; ++j) {
Send(((int64_t{1} << j) & num) != 0 ? 1 : 0);
}
}
Send(b ? 1 : 0);
}
Bruno
#include "Bruno.h"
#include <bits/stdc++.h>
namespace {
constexpr int LG = 63;
constexpr int SZ = 44;
std::vector<std::array<int64_t, 2>> dp;
void init() {
dp.resize(LG + 1);
dp[1][0] = 1;
dp[1][1] = 1;
for (int i = 2; i <= LG; ++i) {
dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
dp[i][1] = dp[i - 1][0];
}
}
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
const int n = N;
const int l = L - 1;
const std::vector<int> a = std::move(A);
init();
std::vector<bool> res(n);
for (int i = 0; i < l; i += SZ) {
int64_t num = 0;
for (int j = 0; j < SZ; ++j) {
if (a[i + j] == 1) {
num |= int64_t{1} << j;
}
}
int64_t val = 0;
for (int j = LG - 1; j >= 0; --j) {
if (num >= dp[j + 1][0]) {
val |= int64_t{1} << j;
num -= dp[j + 1][0];
}
}
for (int j = 0; j < LG; ++j) {
if (((int64_t{1} << j) & val) != 0) {
res[i + j] = true;
}
}
}
int st =
static_cast<int>(std::find(res.begin(), res.end(), true) - res.begin());
for (int i = 0; i < st; ++i) {
Remove(i);
}
if (st == n) {
return;
}
if (a[l] == 1) {
res[st + 1] = true;
}
int orig = st;
while (true) {
int fi = static_cast<int>(std::find(res.begin() + st + 1, res.end(), true) -
res.begin());
for (int j = fi - 1; j > st; --j) {
Remove(j);
}
if (fi == n) {
break;
}
Remove(fi);
st = fi;
}
Remove(orig);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
input:
18 Y X Y Z X Z X X Z Z Y Y Z Y Y Z X X
output:
45 110001000001000000000000000000000000000000000
input:
45 110001000001000000000000000000000000000000000
output:
0 45 3
result:
ok n = 18, D = 45, L = 3
Test #2:
score: 100
Accepted
time: 0ms
memory: 3860kb
input:
18 X Z X Y Y Y X Z X Y Z Z Z Z Y Z Z Y
output:
45 101110010011000000000000000000000000000000001
input:
45 101110010011000000000000000000000000000000001
output:
0 45 3
result:
ok n = 18, D = 45, L = 3
Test #3:
score: 100
Accepted
time: 2ms
memory: 3712kb
input:
18 Y Z Z Y Z X X Z Y Y Z Z Z Y X X Z Y
output:
45 000000111101000000000000000000000000000000000
input:
45 000000111101000000000000000000000000000000000
output:
0 45 2
result:
ok n = 18, D = 45, L = 2
Test #4:
score: 100
Accepted
time: 2ms
memory: 3788kb
input:
18 X Z Z X Z X X Z X Y Y X X Z X Y Z X
output:
45 000101010011000000000000000000000000000000000
input:
45 000101010011000000000000000000000000000000000
output:
0 45 2
result:
ok n = 18, D = 45, L = 2
Test #5:
score: 100
Accepted
time: 2ms
memory: 3788kb
input:
18 X Y X Y Y X X Z Y Z Y X Z Y Y X X Z
output:
45 010100100100100000000000000000000000000000000
input:
45 010100100100100000000000000000000000000000000
output:
0 45 5
result:
ok n = 18, D = 45, L = 5
Test #6:
score: 100
Accepted
time: 2ms
memory: 4028kb
input:
18 X X Y Z X Y Y Y X X Z X X X Z X Z Z
output:
45 011000110010100000000000000000000000000000000
input:
45 011000110010100000000000000000000000000000000
output:
0 45 2
result:
ok n = 18, D = 45, L = 2
Test #7:
score: 100
Accepted
time: 2ms
memory: 4032kb
input:
3 X Y Z
output:
45 001000000000000000000000000000000000000000000
input:
45 001000000000000000000000000000000000000000000
output:
0 45 1
result:
ok n = 3, D = 45, L = 1
Test #8:
score: 100
Accepted
time: 0ms
memory: 3704kb
input:
3 Z Y X
output:
45 110000000000000000000000000000000000000000000
input:
45 110000000000000000000000000000000000000000000
output:
0 45 0
result:
ok n = 3, D = 45, L = 0
Test #9:
score: 100
Accepted
time: 2ms
memory: 4028kb
input:
18 X X X X X X X X X X X X X X X X X X
output:
45 100000000000000000000000000000000000000000000
input:
45 100000000000000000000000000000000000000000000
output:
0 45 0
result:
ok n = 18, D = 45, L = 0
Test #10:
score: 100
Accepted
time: 2ms
memory: 3788kb
input:
18 Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
output:
45 000000000000000000000000000000000000000000000
input:
45 000000000000000000000000000000000000000000000
output:
0 45 0
result:
ok n = 18, D = 45, L = 0
Test #11:
score: 100
Accepted
time: 2ms
memory: 3984kb
input:
18 Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z
output:
45 000000000000000000000000000000000000000000000
input:
45 000000000000000000000000000000000000000000000
output:
0 45 0
result:
ok n = 18, D = 45, L = 0
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 30ms
memory: 9684kb
input:
100000 X Z X Z Z X Y Z Y X Y X Z Z Z Y X Z Y X Y Y X Y Y Y Z Y Z Z Y X X Y X X Y Y X X X Z Y Y Y Z Z Z Z Y X Y Y Z Z Z X Y Z X X X X Y X Y X X Z X Z Z Z X Y X X X Z X Z X X X Y Y Y Y Z X X Y Z Y Y X Z X Z Z Z Z Z Y Z Y X Y Y Y Y X Z Z Y Z Z Y Z Z Z X Z Z X X Z Z Z Z X X Z Y Y Z Y Y Z Z Y Y Z Y Z Y Z...
output:
69873 110001000001111001010010010100010000001110000010100111111100001101101101010101101101001000111001010100111010010000010111101010000110110001110000000110111110111111011110100100010100101000000111101100011101101110110011111001010011001111111000000110110110101000010110111111100001100000111001111001...
input:
69873 110001000001111001010010010100010000001110000010100111111100001101101101010101101101001000111001010100111010010000010111101010000110110001110000000110111110111111011110100100010100101000000111101100011101101110110011111001010011001111111000000110110110101000010110111111100001100000111001111001...
output:
0 69873 5447
result:
wrong answer your query is valid but your solution is not optimal: read 5447 but expected 22133