## CCC '97 S1 - Sentences

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Write a program which accepts as input a list of subjects, a list of verbs, and a list of objects, and produces all possible sentences which consist of a subject, a verb, and an object.

#### Input Specification

The first line of the input file contains a positive integer which is the number of data sets which follow.

For each of the data sets, the data begins with positive integers, one per line, each less than or equal to , which represent the number of subjects, verbs, and objects, respectively, which are provided. Following this line are the subjects, one per line in alphabetical order, the verbs, one per line in alphabetical order, and the objects, one per line in alphabetical order.

The maximum length of any subject, predicate or object is characters.

#### Output Specification

The output is to consist of all possible sentences which can be formed using one subject, one verb, and one object, and is to be output in alphabetical order with a period at the end of each sentence. The output for different data sets are to be separated by a single blank line.

#### Sample Input

1
3
3
2
He
The cat
The dog
bit
kicked
saw
him
the mouse

#### Sample Output

He bit him.
He bit the mouse.
He kicked him.
He kicked the mouse.
He saw him.
He saw the mouse.
The cat bit him.
The cat bit the mouse.
The cat kicked him.
The cat kicked the mouse.
The cat saw him.
The cat saw the mouse.
The dog bit him.
The dog bit the mouse.
The dog kicked him.
The dog kicked the mouse.
The dog saw him.
The dog saw the mouse.

• commented on Feb. 11, 2020, 11:07 p.m.

I forgot the periods lol and it got me debugging for hours

• commented on Nov. 16, 2019, 10:24 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Dec. 9, 2019, 2:54 p.m.

Write a program which accepts as input a list of subjects, a list of verbs, and a list of objects, and produces all possible sentences which consist of a subject, a verb, and an object.

Input Specification The first line of the input file contains a positive integer n which is the number of data sets which follow.

For each of the n data sets, the data begins with 3 positive integers, one per line, each less than or equal to 20, which represent the number of subjects, verbs, and objects, respectively, which are provided. Following this line are the subjects, one per line in alphabetical order, the verbs, one per line in alphabetical order, and the objects, one per line in alphabetical order.

The maximum length of any subject, predicate or object is 25 characters.

Output Specification The output is to consist of all possible sentences which can be formed using one subject, one verb, and one object, and is to be output in alphabetical order with a period at the end of each sentence. The output for different data sets are to be separated by a single blank line.