Home > Back-end >  Novice small white can't find out their own wrong data for help you
Novice small white can't find out their own wrong data for help you

Time:10-09

To see a doctor to line up

The doctor is the earth the person all know to line up the common sense,
But after careful observation of 0068, he found the hospital queue is to have cultured, 0068 to the hospital with three doctors (sweat, less so) at the same time to see the doctor, and the doctor has weight, so can't according to the principle of simple first come, first service, so the hospital 10 different is defined for each condition of priority, the level of 10 has the highest priority, the lowest priority level is 1, the doctor in to see the doctor, will be in his team select a man of highest priority to make a diagnosis and give treatment, if encounter two priorities as patients, select the earliest to line up of patients,

Now please help hospital the treatment process simulation,

Input data contains multiple sets of test, please process to the end of the file,
Each group of data is the first line there is a positive integer N (0 & lt; N<2000) said the number of events,
The events of the next N lines respectively,
There are two types of events:
1: "IN A to B," said one has priority B patients asked the doctor to make A diagnosis and give treatment, (0 & lt; A<3, 0=& lt; B<=10)
2: "OUT of A", said A doctor conducted A make A diagnosis and give treatment, after treatment, the patient discharged from hospital, (0 & lt; A
=3)
For each "OUT A" events, output is in one line, please make A diagnosis and give treatment of number ID, if the event is no patients need to make A diagnosis and give treatment, the output "EMPTY",
Diagnosis and treatment of number ID is defined as: IN A set of tests, "IN A B" incident the first K times, patient ID for K, namely number starting from 1

The Sample Input
7
IN 1 1
2 IN 1
OUT 1
OUT 2
2 IN 1
OUT 2
OUT 1
2
IN 1 1
OUT 1

The Sample Output
2
The EMPTY
3
1
1


Here is my code though no priority queue but I'm still trying to figure out where is wrong cry
#include
#include
#include
using namespace std;
Struct CJJ
{
int a;//select the doctor
Int b;//priority
Int c;//number
Int d=0;//will be make a diagnosis and give treatment
} BRR [3000];
Bool CMP (CJJ CJJ m, n)
{
If (m.==n.a.) return m.b & gt; N.b.
The else return m. & lt; N.a.;
}
Int main (void)
{
Int N;
Char cmp1 [5]="IN", cmp2 [5]="OUT";
While (~ the scanf (" % d ", & amp; N))
{
for(int i=0; i<2010; I++)
{BRR [I]. C=0; BRR [I] d=0; }//reset
Int j=0;
Int cnt1 [3]={0}, cnt2 [3]={0};//cnt1 records patients and doctors in hand cnt2 record the total number of patients
for(int i=0; i{
Char arr [5]={} '\ 0';
The scanf (" % s ", arr);
If (STRCMP (arr, cmp1)==0)
{
The scanf (" % d % d ", & amp; BRR [j]. J a, & amp; BRR [j]. B);
BRR [j]. J c=j + 1;
Cnt1 [BRR [j] a - 1] + +; Cnt2 [BRR [j] a - 1] + +; j++;
}
If (STRCMP (arr, cmp2)==0)
{
Sort (BRR, BRR + j, CMP);
Int k;
Int u;
The scanf (" % d ", & amp; K);
If (cnt1] [k - 1==0) printf (" the EMPTY \ n ");
The else
{
If (k==3) u=cnt2 cnt2 [0] + [1].
If (k==2) u=cnt2 [0].
If (k==1) u=0;//optimization cycle start
}
for(; u{
If (BRR [u] a==k& & BRR [u] d==0) {printf (" % d \ n ", BRR [u] c); BRR [u] d=1; Cnt1 [BRR [u] a - 1] --; break; }
}
}
}

}
return 0;
}

CodePudding user response:

Thank you for your great kagyu
  • Related