Task: | Flash memory |
Sender: | vgtcross |
Submission time: | 2023-04-18 14:22:11 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 32 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 31.5 |
test | verdict | time | score | |
---|---|---|---|---|
#1 | ACCEPTED | 0.43 s | 2.7 | details |
#2 | ACCEPTED | 0.25 s | 1.75 | details |
#3 | ACCEPTED | 0.23 s | 2.4 | details |
#4 | ACCEPTED | 0.14 s | 1.4 | details |
#5 | ACCEPTED | 0.14 s | 1.55 | details |
#6 | ACCEPTED | 0.14 s | 2.45 | details |
#7 | ACCEPTED | 0.09 s | 1.2 | details |
#8 | ACCEPTED | 0.09 s | 1.15 | details |
#9 | ACCEPTED | 0.09 s | 1.4 | details |
#10 | ACCEPTED | 0.08 s | 2.45 | details |
#11 | ACCEPTED | 0.06 s | 0.85 | details |
#12 | ACCEPTED | 0.06 s | 0.95 | details |
#13 | ACCEPTED | 0.06 s | 1.05 | details |
#14 | ACCEPTED | 0.06 s | 1.4 | details |
#15 | ACCEPTED | 0.06 s | 2.45 | details |
#16 | ACCEPTED | 0.04 s | 0.75 | details |
#17 | ACCEPTED | 0.04 s | 0.85 | details |
#18 | ACCEPTED | 0.04 s | 1 | details |
#19 | ACCEPTED | 0.04 s | 1.3 | details |
#20 | ACCEPTED | 0.04 s | 2.45 | details |
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int t, b, m; cin >> t >> b >> m; bitset<512> B, B2, M, M2, O; if (t == 0) { while (true) { int c; cin >> c; if (c == 0) return; cin >> B2 >> M2; for (int i = 0; i < b; ++i) B[b-1-i] = B2[i]; for (int i = 0; i < m; ++i) M[m-1-i] = M2[i]; if (M == 0 && B != 0) { cout << 0 << endl; continue; } int ui = 0; for (int step = b/m-1; step >= 0; --step) { bool used = 0; for (int i = 0; i < m; ++i) if (B[m*step + i]) { used = 1; break; } if (used) { ui = step+1; break; } } bool bad = 1; if (ui > 0) { O = B & ~(M << ((ui-1)*m)); bool works = 1; for (int i = 0; i < m; ++i) if (O[(ui-1)*m + i]) works = 0; if (works) { cout << "1\n"; O = B | (M << ((ui-1)*m)); for (int i = 0; i < b; ++i) { cout << O[i]; } cout << endl; bad = 0; } } if (bad && ui < b/m) { cout << "1\n"; O = B | (M << (ui*m)); for (int i = 0; i < b; ++i) { cout << O[i]; } cout << endl; bad = 0; } if (bad) { cout << 0 << endl; } } } else { while (true) { int c; cin >> c; if (c == 0) return; cin >> B2; for (int i = 0; i < b; ++i) B[b-1-i] = B2[i]; bool used = 0; for (int step = b/m - 1; step >= 0; --step) { for (int i = 0; i < m; ++i) if (B[m*step + i]) { used = 1; break; } if (used) { for (int i = 0; i < m; ++i) { cout << B[m*step + i]; } cout << endl; break; } } if (!used) { for (int i = 0; i < m; ++i) { cout << 0; } cout << endl; } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
16 8 4.062445024495069624056 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 16 8 1 0000000000000000 11110001 ... Truncated |
Error:
1 1 54 0
Test 2
Verdict: ACCEPTED
input |
---|
32 8 12.264904841300964834177 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 32 8 1 000000000000000000000000000000... Truncated |
Error:
1 1 35 0
Test 3
Verdict: ACCEPTED
input |
---|
32 16 4.129591513707784802006 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 32 16 1 000000000000000000000000000000... Truncated |
Error:
1 1 48 0
Test 4
Verdict: ACCEPTED
input |
---|
64 8 30.039277894268828900030 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 64 8 1 000000000000000000000000000000... Truncated |
Error:
1 1 28 0
Test 5
Verdict: ACCEPTED
input |
---|
64 16 12.953148094217360432715 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 64 16 1 000000000000000000000000000000... Truncated |
Error:
1 1 31 0
Test 6
Verdict: ACCEPTED
input |
---|
64 32 4.073559788233661501537 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 64 32 1 000000000000000000000000000000... Truncated |
Error:
1 1 49 0
Test 7
Verdict: ACCEPTED
input |
---|
128 8 69.777892228928747548775 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 128 8 1 000000000000000000000000000000... Truncated |
Error:
1 1 24 0
Test 8
Verdict: ACCEPTED
input |
---|
128 16 34.73179127514363524097... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 128 16 1 000000000000000000000000000000... Truncated |
Error:
1 1 23 0
Test 9
Verdict: ACCEPTED
input |
---|
128 32 13.95078898770563890866... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 128 32 1 000000000000000000000000000000... Truncated |
Error:
1 1 28 0
Test 10
Verdict: ACCEPTED
input |
---|
128 64 4.039918210604800133907 |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 128 64 1 000000000000000000000000000000... Truncated |
Error:
1 1 49 0
Test 11
Verdict: ACCEPTED
input |
---|
256 8 174.46804708607103851145... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 256 8 1 000000000000000000000000000000... Truncated |
Error:
1 1 17 0
Test 12
Verdict: ACCEPTED
input |
---|
256 16 82.22261415140417733455... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 256 16 1 000000000000000000000000000000... Truncated |
Error:
1 1 19 0
Test 13
Verdict: ACCEPTED
input |
---|
256 32 37.62938226976920648891... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 256 32 1 000000000000000000000000000000... Truncated |
Error:
1 1 21 0
Test 14
Verdict: ACCEPTED
input |
---|
256 64 14.26346228205414057768... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 256 64 1 000000000000000000000000000000... Truncated |
Error:
1 1 28 0
Test 15
Verdict: ACCEPTED
input |
---|
256 128 4.01556909389394343085... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 256 128 1 000000000000000000000000000000... Truncated |
Error:
1 1 49 0
Test 16
Verdict: ACCEPTED
input |
---|
512 16 204.7462421274103461702... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 512 16 1 000000000000000000000000000000... Truncated |
Error:
1 1 15 0
Test 17
Verdict: ACCEPTED
input |
---|
512 32 91.77859514807311153984... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 512 32 1 000000000000000000000000000000... Truncated |
Error:
1 1 17 0
Test 18
Verdict: ACCEPTED
input |
---|
512 64 39.23027924214593871262... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 512 64 1 000000000000000000000000000000... Truncated |
Error:
1 1 20 0
Test 19
Verdict: ACCEPTED
input |
---|
512 128 15.0000000021676722686... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 512 128 1 000000000000000000000000000000... Truncated |
Error:
1 1 26 0
Test 20
Verdict: ACCEPTED
input |
---|
512 256 4.00542327711105546887... |
correct output |
---|
(empty) |
user output |
---|
Activating encoder mode 0 512 256 1 000000000000000000000000000000... Truncated |
Error:
1 1 49 0