CSES - Leirikisa 2 - Results
Submission details
Task:Flash memory
Sender:a256
Submission time:2023-04-18 14:02:57 +0300
Language:C++ (C++11)
Status:READY
Result:22
Feedback
groupverdictscore
#1ACCEPTED22.3
Test results
testverdicttimescore
#1ACCEPTED0.33 s1.2details
#2ACCEPTED0.21 s1.35details
#3ACCEPTED0.18 s1.2details
#4ACCEPTED0.12 s1.25details
#5ACCEPTED0.12 s1.3details
#6ACCEPTED0.11 s1.2details
#7ACCEPTED0.08 s1.15details
#8ACCEPTED0.08 s1.1details
#9ACCEPTED0.08 s1.2details
#10ACCEPTED0.07 s1.2details
#11ACCEPTED0.05 s0.95details
#12ACCEPTED0.05 s0.95details
#13ACCEPTED0.05 s1details
#14ACCEPTED0.05 s1.15details
#15ACCEPTED0.05 s1.2details
#16ACCEPTED0.03 s0.8details
#17ACCEPTED0.03 s0.85details
#18ACCEPTED0.03 s0.95details
#19ACCEPTED0.04 s1.1details
#20ACCEPTED0.03 s1.2details

Code

#include <bits/stdc++.h>
using namespace std;
int T,B,M,C;
string s,t;

void lue(){
	for(;;){
		cin>>C;
		if(!C) return;
		cin>>s;
		for(int i=s.size()-1;i>=M;--i){
			if(s[i]=='1'){
				for(int j=i-M;j<i;++j) cout<<s[j];
				cout<<endl;
				break;
			}
		}
	}
}

void kirjoita(){
	for(;;){
		cin>>C;
		if(!C) return;
		cin>>s>>t;
		int i;
		for(i=s.size()-1;i>=0&&s[i]=='0';--i){
			;
		}
		i+=1;
		if(B-i < M+1){
			cout<<'0'<<endl;
		} else {
			cout<<"1\n";
			if(i-1-M>=0&&strncmp(s.c_str()+i-1-M,t.c_str(),t.size())==0){
				;
			} else {
				int p=0;
				for(int j=1;j<(int)t.size()&&i-j>=0;++j){
					bool b=1;
					for(int k=0;k<j;++k){
						if(t[k]!=s[i-j+k]){
							b=0;
							break;
						}
					}
					if(b)
						p=j;
				}
				copy(t.begin()+p,t.end(),s.begin()+i);
				s[i+M-p]='1';
			}
			cout<<s<<endl;
		}
	}
}

int main(){
	cin>>T>>B>>M;
	if(T==0) kirjoita();
	else lue();
}

Test details

Test 1

Verdict: ACCEPTED

input
16 8 4.062445024495069624056

correct output
(empty)

user output
Activating encoder mode
0
16 8
1
0000000000000000 10110000
...
Truncated

Error:
1 1 24 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 27 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 24 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 26 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 24 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 23 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 22 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 24 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 24 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 19 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 20 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 23 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 24 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 16 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 19 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 22 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 24 0