编程介的小学生 2017-11-03 23:37 采纳率: 20.5%
浏览 761
已采纳

Regroup

Problem Description
When ALPC42 got to a panzer brigade, He was asked to build software to help them regroup the battalions or companies.
As the tradition of army, soldiers are rated according his or her abilities, taking the rate as an integer. The fighting capacity of a company is determined by the soldier in this company whose rate is lowest. Now the recruits those rated are coming and join to their companies according to the order form HQ.
With the coming of new recruits, a big regroup action reached, asking to merge some companies into one. The designation of a company, however, will not be canceled, but remain for memorialize what the company is done, means the designation of the company is still exist, but the company is gone, so it is unable to ask recruits to join this company, or merge the company into others.
A strange thing is, the orders sometimes get wrong, send newbie to a company which is already merged into another, or mentioned some only-designation-existed companies. Such order could be rejected.
The brigadier wants to know every change of each order, so the program should able to report the status of every order, telling whether it is accept, and can query the fighting capacity of specified company. (To simplify, companies are numbered from 0 to n-1

Input
There may be several test cases.
For each case, the integers in first line, n, k, m, telling that there are n companies, k soldiers already, and m orders needs be executed. (1<=n ,k ,m<=100000).
Then k lines with two integers R and C for each, telling a soldier with rate R is now in company C
Then m lines followed, containing 3 kinds of orders, in upper case:
AP x y
A recruit with ability rate x were asked to join company y. (0<=x<2^31, 0<=y<n)

MG x y
Company x and company y is merged. The new company is numbered as x. (0<=x, y<n)

GT x
Report the fighting capacity of company x. (0<=x<n)

Output
For each order there is exact one line to report the result.
For AP and MG order, print “Accept” if it is able to be done, and execute it, or “Reject” if it is an illegal order.
For GT order, if company x is still exist (not merged into others), print as “Lowest rate: y.” which y is the minimal rate of soldiers in this company. If there is no one in this company, tell "Company x is empty." If company x is already merged into others, print "Company x is a part of company z." z is the company where the company x is in.
Print a blank line after each case

Sample Input
5 5 10
5 0
5 1
5 2
5 1
5 0
GT 0
GT 3
AP 3 3
GT 3
GT 4
MG 3 4
GT 4
MG 1 3
GT 4
GT 1

Sample Output
Lowest rate: 5.
Company 3 is empty.
Accept
Lowest rate: 3.
Company 4 is empty.
Accept
Company 4 is a part of company 3.
Accept
Company 4 is a part of company 1.
Lowest rate: 3.

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-29 15:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)