The various departments of Swamp County College are working on their
instructor schedules for the upcoming semester. As part of this
planning process, the college administrators want to make sure that the
instructor assignments for
class days and times are spread equitably among the faculty. The college
has the instructor and course section data for the past several semesters,
and the administrators want to be able to query this information to see
which instructors have taught on given days or times.
The past course section data are in a file named sections.csv with one
course section per line.
Each line consists of a number of fields, with the field values separated from
each other by commas.
The fields appear in the following order:
Term: A string consisting of "Fall" or "Sprng" followed by a single space
and the four-digit year
Class Num: The number of the course, an unsigned integer in the range
1-99999
Class Section Cd: The section number for this class, an unsigned integer
in the range 1-99999
Mon, Tue, Wed, Thu, Fri, Sat, Sun: Days when the class meets (Y or N for each day of the week)
Meeting Time Start: Time of day when the class starts, as hh:mm AM/PM
Meeting Time End: Time of day when the class ends, as hh:mm AM/PM
Instructor ID: Instructor's employee ID (nine digit unsigned integer, may include leading zeroes)
It is possible for the same class to have multiple instructors assigned.
Each instructor receives credit for teaching during the specified
times. Instructors do not teach multiple classes concurrently, nor do any
instructor class times overlap-there are therefore no duplicate entries
in the sections.csv file.
Your team has been asked to write a utility that administrators can use to
query this data. Each query will appear on a separate line of not more than
80 columns. Elements within a query are separated from each other by one or
more spaces. Queries contain three parts: a function, a range
limit, and a day/time range specification.
The function will be "LIST" (list the IDs of the instructors that meet the
selection
criteria) or "COUNT" (count the instructors that meet the selection criteria).
Any requested list is to be produced in ascending instructor ID order.
The limit will be "ANY", "ALL", or an inequality character ( < or > )
immediately followed by a percentage.
"ANY" means that the instructor is selected if any of the time he or she
spent teaching (in any term) falls in the desired range.
"ALL" means that the instructor is selected if all the time he or she spent
teaching in all terms falls in the desired range.
A less than or greater than sign followed by a percentage means that the
instructor is selected if less (or more) than the specified percentage of
the instructor's total time spent teaching in all terms falls in the
desired range.
The day/time range specification will contain a day list, a time specification,
or both. A day list begins with the word "ON", followed by an optional
"NOT" and one or more days of the week in any order. The days of the week are
represented by their three letter abbreviations: "MON", "TUE", "WED",
"THU", "FRI",
"SAT", and "SUN". The selection criteria then include (or exclude, if
"NOT" is specified) the given days of the week. No weekday will appear
more than once in a given query.
The time specification will contain the word "BEFORE" or "AFTER"
followed by
a time (hh:mm) followed by "AM" or "PM". The selection criteria then
include all time spent teaching before or after the specified time (inclusive).
Note that a "NOT" in the query only affects the day list, not the time
specification.
Here are descriptions of the queries in the sample input:
LIST ANY ON SAT
List the instructors who taught at any time on Saturday.
COUNT ALL ON NOT FRI SAT SUN
Count the number of instructors who did not teach at any time on
Friday, Saturday, or Sunday.
LIST >75% ON TUE THU AFTER 7:00 PM
List the instructors who taught 75% or more of their total teaching time on
Tuesdays and/or Thursdays at 7 PM or later.
COUNT ALL BEFORE 11:30 AM
Count the number of instructors whose classes always finished no
later than 11:30 AM.
LIST ALL ON SUN
List the instructors who only taught on Sunday.
A sample sections.csv file is available with the "getdata" command.
sections.csv will be available to your submission in your execution
current working directory. The judges' version of sections.csv may
differ from the sample version. There will no more than
10 terms in the file, and there will be no more than 3,000 course sections in
any given term.
Your program is to echo each query as it appears in the input on a
separate line, followed by the result of the query. Lists should appear in
instructor ID order, one instructor ID per line, beginning in the first
column without trailing whitespace. Counts should appear as unsigned integers
beginning in the first column without trailing whitespace. Print an empty
line after the results of each query (including the last). Should a list
query return no results, print a line with the message
"No instructors found." as the result.
Sample Input
LIST ANY ON SAT
COUNT ALL ON NOT FRI SAT SUN
LIST >75% ON TUE THU AFTER 7:00 PM
COUNT ALL BEFORE 11:30 AM
LIST ALL ON SUN
Output for the Sample Input
LIST ANY ON SAT
000002925
000005499
000012103
000014547
000014976
000018148
000021814
000022321
000027885
000760180
001650797
002174437
002403107
COUNT ALL ON NOT FRI SAT SUN
499
LIST >75% ON TUE THU AFTER 7:00 PM
000002587
000004069
000020488
000027326
000032786
000063796
000480342
000551088
002144680
002397582
002486840
COUNT ALL BEFORE 11:30 AM
25
LIST ALL ON SUN
No instructors found.
File translated from
TEX
by
TTH,
version 3.77. On 17 Nov 2007, 22:18.