CSES - Leirikisa 2 - Results
Submission details
Task:Flash memory
Sender:vgtcross
Submission time:2023-04-18 14:22:11 +0300
Language:C++ (C++11)
Status:READY
Result:32
Feedback
groupverdictscore
#1ACCEPTED31.5
Test results
testverdicttimescore
#1ACCEPTED0.43 s2.7details
#2ACCEPTED0.25 s1.75details
#3ACCEPTED0.23 s2.4details
#4ACCEPTED0.14 s1.4details
#5ACCEPTED0.14 s1.55details
#6ACCEPTED0.14 s2.45details
#7ACCEPTED0.09 s1.2details
#8ACCEPTED0.09 s1.15details
#9ACCEPTED0.09 s1.4details
#10ACCEPTED0.08 s2.45details
#11ACCEPTED0.06 s0.85details
#12ACCEPTED0.06 s0.95details
#13ACCEPTED0.06 s1.05details
#14ACCEPTED0.06 s1.4details
#15ACCEPTED0.06 s2.45details
#16ACCEPTED0.04 s0.75details
#17ACCEPTED0.04 s0.85details
#18ACCEPTED0.04 s1details
#19ACCEPTED0.04 s1.3details
#20ACCEPTED0.04 s2.45details

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