Task: | Flash memory |
Sender: | DualRed |
Submission time: | 2023-04-18 14:42:44 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 31 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 30.7 |
test | verdict | time | score | |
---|---|---|---|---|
#1 | ACCEPTED | 0.36 s | 2.4 | details |
#2 | ACCEPTED | 0.21 s | 1.6 | details |
#3 | ACCEPTED | 0.20 s | 2.4 | details |
#4 | ACCEPTED | 0.12 s | 1.25 | details |
#5 | ACCEPTED | 0.12 s | 1.5 | details |
#6 | ACCEPTED | 0.12 s | 2.45 | details |
#7 | ACCEPTED | 0.07 s | 1.05 | details |
#8 | ACCEPTED | 0.07 s | 1.15 | details |
#9 | ACCEPTED | 0.07 s | 1.4 | details |
#10 | ACCEPTED | 0.07 s | 2.45 | details |
#11 | ACCEPTED | 0.05 s | 0.85 | details |
#12 | ACCEPTED | 0.05 s | 0.95 | details |
#13 | ACCEPTED | 0.05 s | 1.05 | details |
#14 | ACCEPTED | 0.05 s | 1.4 | details |
#15 | ACCEPTED | 0.04 s | 2.45 | details |
#16 | ACCEPTED | 0.03 s | 0.75 | details |
#17 | ACCEPTED | 0.03 s | 0.85 | details |
#18 | ACCEPTED | 0.03 s | 1 | details |
#19 | ACCEPTED | 0.03 s | 1.3 | details |
#20 | ACCEPTED | 0.03 s | 2.45 | details |
Code
#include<bits/stdc++.h> using namespace std; typedef long long int ll; int B, M; int logB; void reading(){ string state; cin >> state; for(int s = B-M; s >= 0; s -= M){ bool b = false; for(int i = 0; i < M; i++){ if(state[s+i] == '1') b = true; } if(b){ cout << state.substr(s, M) << endl; break; } } /*string state; cin >> state; int index = 0; for(int i = logB-1; i >= 0; i--){ if(state[i] == '1') index += pow(2, logB-i-1); } string result = state.substr(index, M); cout << result << endl;*/ } void writing(){ string state, value; cin >> state >> value; bool b = false; for(int i = 0; i < M; i++){ if(value[i] == '1') b = true; } if(!b){ cout << "0" << endl; return; } bool found = false; for(int s = 0; s < B; s += M){ bool b = false; for(int i = 0; i < M; i++){ if(state[s+i] == '1') b = true; } if(!b){ for(int i = 0; i < M; i++){ if(value[i] == '1') state[s+i] = '1'; else state[s+i] = '0'; } found = true; break; } } if(!found) cout << "0" << endl; else{ cout << "1" << endl; cout << state << endl; } /*bool found = false; string result; for(int i = 0; i <= B-M; i++){ string test = state; bool correct = true; for(int k = logB-1; k >= 0; k--){ if(!(i & (1 << k)) && test[logB-k-1] == '1'){ correct = false; break; } else if(i & (1 << k)) test[logB-k-1] = '1'; else test[logB-k-1] = '0'; } if(!correct) continue; for(int p = 0; p < M; p++){ if(i+p < logB && test[i+p] != value[p]){ correct = false; break; } else if(test[i+p] == '1' && value[p] == '0'){ correct = false; break; } else test[i+p] = value[p]; } if(correct){ found = true; result = test; break; } } if(!found) cout << 0 << endl; else{ cout << 1 << endl; cout << result << endl; }*/ } /* 0 16 8 1 0000000000000000 11001011 0 ------- 1 16 8 1 0011100101100000 0 */ int main(){ cin.tie(0)->sync_with_stdio(0); int T; cin >> T; cin >> B >> M; logB = log2(B); if(T == 0){ int C; while(true){ cin >> C; if(C == 0) break; writing(); } } else if(T == 1){ int C; while(true){ cin >> C; if(C == 0) break; reading(); } } else assert(false); 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 01110001 ... Truncated |
Error:
1 1 48 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 32 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 25 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 30 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 21 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