In response to popular demand, Dan’s established two research groups A and B composed of his n graduate students. Each of these students is a member of exactly one of the two groups at any given time. The students are numbered from 1 to n in some arbitrary order. To measure the success of his research groups, Dan assigns a citation score to each of them. Initially, both groups have citation score 0. Throughout the semester, events of the following two types happen: Studentxpublishesapaperinwhichtheycitestudenty’swork(youcan assume all of the students have been around long enough to have prior research that can be cited). As a result, If x and y are in the same group, their group’s citation score increases by 1. If x and y are in different groups, y’s group’s citation score increases by 5. Danchangesstudentx’sgroup(fromAtoBorfromBtoA)tohavethem work on different projects. To assess the overall success of the research groups, Dan needs to calculate their final citation scores at the end of the semester. Help him do so by writing a program that reports the final scores given a description of the events occurring throughout the semester. Filename Your filename for this question must be q1.py. Input The first line of the input contains two integers n and m separated by a single space. n denotes the number of Dan’s students and m denotes the number of events. The second line contains n letters separated by single spaces. The i-th letter is either “A” or “B”. If it’s “A”, the i-th student is initially in group A; Otherwise, the i-th student is initially in group B. The next m lines describe the events in chronological order. Each line describes a single event. If a line starts with the string cite, two integers x and y follow, indicating that student x has published a paper in which they cite student y’s work. Otherwise, the line starts with the string change, which is followed by a single integer x. This indicates that Dan has changed student x’s group. Output Print two integers separated by a single space. These should indicate the final citation scores of groups A and B, respectively.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In response to popular demand, Dan’s established two research groups A and B composed of his n graduate students. Each of these students is a member of exactly one of the two groups at any given time. The students are numbered from 1 to n in some arbitrary order.

To measure the success of his research groups, Dan assigns a citation score to each of them. Initially, both groups have citation score 0. Throughout the semester, events of the following two types happen:

  1. Studentxpublishesapaperinwhichtheycitestudenty’swork(youcan assume all of the students have been around long enough to have prior research that can be cited). As a result,

    If x and y are in the same group, their group’s citation score increases by 1.

    If x and y are in different groups, y’s group’s citation score increases by 5.

  2. Danchangesstudentx’sgroup(fromAtoBorfromBtoA)tohavethem

    work on different projects.

To assess the overall success of the research groups, Dan needs to calculate their final citation scores at the end of the semester. Help him do so by writing a program that reports the final scores given a description of the events occurring throughout the semester.

Filename

Your filename for this question must be q1.py.

Input

The first line of the input contains two integers n and m separated by a single space. n denotes the number of Dan’s students and m denotes the number of events.

The second line contains n letters separated by single spaces. The i-th letter is either “A” or “B”. If it’s “A”, the i-th student is initially in group A; Otherwise, the i-th student is initially in group B.

The next m lines describe the events in chronological order. Each line describes a single event. If a line starts with the string cite, two integers x and y follow, indicating that student x has published a paper in which they cite student y’s work.

Otherwise, the line starts with the string change, which is followed by a single integer x. This indicates that Dan has changed student x’s group.

Output

Print two integers separated by a single space. These should indicate the final citation scores of groups A and B, respectively.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

When I go to type my input it does let me add a single space also the second line here 
m = int(input()) it's not supposed to be an integer. 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education