CF642A.Scheduler for Invokers
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
On the start your program reads the following data from standard input:
- in the first line you are given an integer number t ( 1<=t<=500 ) — the number of available invokers (all invokers work simultaneously and independently, free invoker starts testing a job as soon as it is appointed to him);
- in the second line you are given an integer number p ( 1<=p<=10000 ) — the number of problems, submissions to which are expected to be tested.
Further p lines with description of problems are followed. Each description contains problem time limit (integer number between 250 and 30000) and the number of tests (from 1 to 1000).
The following data is given in interactive mode. It means that a following block of data will be available only after your scheduler writes information of its behavior on the previous tick. Firstly, block of data about new submissions, needed to be tested, follows for a tick. Each submission is described by single integer number — index of the problem (from 0 to p−1 ). The value -1 means that there are no new submissions, needed to be tested, in this tick.
Further block of testing results (from invokers) in this tick follows. These lines contain three elements: index of submission, a number of test and the verdict of test (OK or RJ). The block of testing results ends with a line "-1 -1".
Consider that problems and tests are numbered (from zero) in the order of its appearance. Total number of submissions for one test does not exceed 20000.
输入格式
After reading the data about the next tick your scheduler can decide to send submissions for exact testing. The submission can be tested in any test at any time. Your scheduler must output a couple of integers — index of submission and a number of test in a single line in order to start a test for the submission. If there are a free invoker, a testing of a submission immediately begins (invoker becomes busy until the result comes back). Otherwise, your request will be ignored. When you are done sending requests, output line "-1 -1".
You can simply maintain the amount of free invokers in your program, reducing each time variable t while sending the task to invokers (if t=0 , there is no need to send) and increasing t , if invoker returns a verdict.
It is considered that the submission was tested if it was tested on all tests of the problem, or if it was tested on all tests up to first RJ verdict (inclusive).
Interactor breaks out at a time when all the planned submissions will be tested completely. In this case your submission should stop, as soon as it finds closing of input data stream.
输出格式
Materials and tests are available now at http://assets.codeforces.com/files/vk/vkcup-2016-wr2-materials-v1.tar.gz. Please read README.txt to learn how to test your solution with the interactor.
输入输出样例
输入#1
1 1 500 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 OK -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 1 OK -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 0 RJ -1 -1
输出#1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1
说明/提示
Materials and tests are available now at http://assets.codeforces.com/files/vk/vkcup-2016-wr2-materials-v1.tar.gz. Please read README.txt to learn how to test your solution with the interactor.