CSES - Leirikisa 2 - Results
Submission details
Task:Nautilus
Sender:a256
Submission time:2023-04-18 14:01:54 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.00 s2, 3details
#20.00 s1, 2, 3details
#30.00 s1, 2, 3details
#40.00 s1, 2, 3details
#50.00 s1, 2, 3details
#60.00 s1, 2, 3details
#70.00 s1, 2, 3details
#80.00 s2, 3details
#90.00 s2, 3details
#100.00 s2, 3details
#110.00 s2, 3details
#120.00 s2, 3details
#130.00 s2, 3details
#140.00 s2, 3details
#150.00 s2, 3details
#160.00 s2, 3details
#170.00 s2, 3details
#180.00 s2, 3details
#190.00 s2, 3details
#200.00 s2, 3details
#210.00 s2, 3details
#220.00 s2, 3details
#230.00 s3details
#240.00 s3details
#250.00 s3details
#260.00 s3details
#270.00 s3details
#280.00 s3details
#290.00 s3details
#300.00 s3details
#310.00 s3details
#320.00 s3details
#330.00 s3details
#340.00 s3details
#350.00 s3details
#360.00 s3details
#370.00 s3details

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

Group: 2, 3

Verdict:

input
5 9 7
...##....
..#.##..#
..#....##
.##...#..
...

correct output
22

user output
(empty)

Test 2

Group: 1, 2, 3

Verdict:

input
100 100 100
.................................

correct output
8272

user output
(empty)

Test 3

Group: 1, 2, 3

Verdict:

input
100 100 100
.#...#.#..#.....#.........#......

correct output
5

user output
(empty)

Test 4

Group: 1, 2, 3

Verdict:

input
100 100 100
.#...##...#...##....##.#.##..#...

correct output
1

user output
(empty)

Test 5

Group: 1, 2, 3

Verdict:

input
100 100 100
..#.#.#..###.#.#.##..########....

correct output
1

user output
(empty)

Test 6

Group: 1, 2, 3

Verdict:

input
100 100 100
.#.#.###########..#.###.######...

correct output
1

user output
(empty)

Test 7

Group: 1, 2, 3

Verdict:

input
100 100 100
##############################...

correct output
1

user output
(empty)

Test 8

Group: 2, 3

Verdict:

input
100 100 100
.................................

correct output
9503

user output
(empty)

Test 9

Group: 2, 3

Verdict:

input
100 100 100
#..#.##..#....##...#.##.##..#....

correct output
495

user output
(empty)

Test 10

Group: 2, 3

Verdict:

input
100 100 100
#.#...######.#####.#.##...#.##...

correct output
51

user output
(empty)

Test 11

Group: 2, 3

Verdict:

input
100 100 100
.#.#.###########..#.###.######...

correct output
34

user output
(empty)

Test 12

Group: 2, 3

Verdict:

input
100 100 100
##############################...

correct output
19

user output
(empty)

Test 13

Group: 2, 3

Verdict:

input
100 100 100
.................................

correct output
9801

user output
(empty)

Test 14

Group: 2, 3

Verdict:

input
100 100 100
..............#..................

correct output
7479

user output
(empty)

Test 15

Group: 2, 3

Verdict:

input
100 100 100
#.#.........###.#..#.#..####.#...

correct output
5328

user output
(empty)

Test 16

Group: 2, 3

Verdict:

input
100 100 100
.#.#.###########..#.###.######...

correct output
127

user output
(empty)

Test 17

Group: 2, 3

Verdict:

input
100 100 100
##############################...

correct output
19

user output
(empty)

Test 18

Group: 2, 3

Verdict:

input
100 100 100
.................................

correct output
10000

user output
(empty)

Test 19

Group: 2, 3

Verdict:

input
100 100 100
..............#..................

correct output
8047

user output
(empty)

Test 20

Group: 2, 3

Verdict:

input
100 100 100
#.#...######.#####.#.##...#.##...

correct output
3500

user output
(empty)

Test 21

Group: 2, 3

Verdict:

input
100 100 100
.#.#.###########..#.###.######...

correct output
1228

user output
(empty)

Test 22

Group: 2, 3

Verdict:

input
100 100 100
##############################...

correct output
43

user output
(empty)

Test 23

Group: 3

Verdict:

input
500 500 5000
.................................

correct output
249493

user output
(empty)

Test 24

Group: 3

Verdict:

input
500 500 5000
#..#.##..#....##...#.##.##..#....

correct output
222

user output
(empty)

Test 25

Group: 3

Verdict:

input
500 500 5000
.#####....####..###...####.#.#...

correct output
1268

user output
(empty)

Test 26

Group: 3

Verdict:

input
500 500 5000
#.#####.##..#####.####..######...

correct output
805

user output
(empty)

Test 27

Group: 3

Verdict:

input
500 500 5000
##############################...

correct output
349

user output
(empty)

Test 28

Group: 3

Verdict:

input
500 500 5000
.................................

correct output
249999

user output
(empty)

Test 29

Group: 3

Verdict:

input
500 500 5000
..............#..................

correct output
197917

user output
(empty)

Test 30

Group: 3

Verdict:

input
500 500 5000
#.#.........###.#..#.#..####.#...

correct output
79550

user output
(empty)

Test 31

Group: 3

Verdict:

input
500 500 5000
#.#####.##..#####.####..######...

correct output
1221

user output
(empty)

Test 32

Group: 3

Verdict:

input
500 500 5000
##############################...

correct output
1414

user output
(empty)

Test 33

Group: 3

Verdict:

input
500 500 5000
.................................

correct output
250000

user output
(empty)

Test 34

Group: 3

Verdict:

input
500 500 5000
..............#..................

correct output
199752

user output
(empty)

Test 35

Group: 3

Verdict:

input
500 500 5000
.#####....####..###...####.#.#...

correct output
87691

user output
(empty)

Test 36

Group: 3

Verdict:

input
500 500 5000
#.#####.##..#####.####..######...

correct output
30998

user output
(empty)

Test 37

Group: 3

Verdict:

input
500 500 5000
##############################...

correct output
1440

user output
(empty)