[PAT] Class 1026 Table Tennis (30 points) (structure ordering, trick more)

Meaning of the questions:

Enter a positive integer N (<= 10000), represents the client (p) in size, then the input data of N rows, each row comprising a customer scene time, want to play time, and whether VIP customers. Now enter two positive integers K, M (K <= 100, M <= K), and wherein the number of VIP table, which table, which indicates the next input row positive integers M, VIP table, which represents the number of . Started playing time in ascending order in accordance with the output of each customer N line: customers their time and started playing the scene of long waiting times and rounding input, the last line of output for each table, which is the number of services. If the customer does not get the service before 21:00, their data is output.

trick:

Group 8 data contains the data needed to minute rounding, at the beginning useless to take direct translation on rounding found life difficult at this point.

Group 3 data include precisely 21:00 customers arrive, they are not receiving services, at this point to find a long time to find.

Group 7 data includes VIP customers VIP table, which you need to arrange the data and the VIP table, which is not free of data.

Group 5 data table, which contains the VIP customers VIP and VIP table, which is free of data need to arrange.

First and second sets of data containing the current data table, which is not idle.

Fourth and sixth set of data containing the current data no VIP customers.

0 is the first set of data samples.

(For my speculation based on data submitted by different codes, may be wrong, we can only hope a nice ring to take detours)

Casual working for the last sentence:

On the other hand, if when it is the turn of a VIP pair, yet no VIP table is available, they can be assigned as any ordinary players.

Private thought to express the meaning of ordinary players should be ordinary tables. On the other hand, and on the website Codeforces common meaning in other words, which means On the other hand, then the meaning behind the words and the expression is the same but for a way of saying, This question in On the other hand the meaning it should be the other hand, because I often play Codeforces so at first I do question the habit of ignoring on the other hand behind it, but when I later reread the meaning of the questions ordinary players still brought me great distress, This question of the meaning of the title does make this question cast some understanding of the details of the mist.

Code:

#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int table[107];
int tt[107];
int tans[107];
int vipid[10007];
typedef struct customers{
string s;
int t,pt,ft,flg;
};
customers c[10007];
typedef struct ans{
string s;
int t,st;
};
ans a[10007];
bool cmp(customers a,customers b){
return a.t<b.t;
}
bool cmp2(ans a,ans b){
return a.st<b.st;
}
char anss[10007][17];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;++i){
cin>>c[i].s>>c[i].pt>>c[i].flg;
if(c[i].pt>=120)
c[i].pt=120;
c[i].pt*=60;
c[i].t=(c[i].s[0]-'0')*36000+(c[i].s[1]-'0')*3600+(c[i].s[3]-'0')*600+(c[i].s[4]-'0')*60+(c[i].s[6]-'0')*10+c[i].s[7]-'0';
}
int sum,vip;
cin>>sum>>vip;
int x;
for(int i=1;i<=vip;++i){
cin>>x;
table[x]=1;
}
sort(c+1,c+1+n,cmp);
int cnt=0;
for(int i=1;i<=n;++i)
if(c[i].flg)
vipid[++cnt]=i;
int sew=0,mn=1e9,pos=0;
int cntt=1;
for(int i=1;i<=n;++i){
if(a[i].t)
continue;
if(c[i].t>=21*3600)
break;
sew=0,mn=1e9,pos=0;
if(c[i].flg==1){
for(int j=1;j<=sum;++j){
if(!table[j])
continue;
if(tt[j]<=c[i].t){
tt[j]=c[i].t+c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
a[i].st=c[i].t;
++tans[j];
sew=1;
break;
}
if(tt[j]<mn){
mn=tt[j];
pos=j;
}
}
if(sew)
continue;
for(int j=1;j<=sum;++j){
if(tt[j]<=c[i].t){
tt[j]=c[i].t+c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
a[i].st=c[i].t;
++tans[j];
sew=1;
break;
}
if(tt[j]<mn){
mn=tt[j];
pos=j;
}
}
if(sew)
continue;
if(tt[pos]<21*3600){
a[i].st=tt[pos];
tt[pos]+=c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
++tans[pos];
}
continue;
}
sew=0,mn=1e9,pos=0;
for(int j=1;j<=sum;++j){
if(tt[j]<=c[i].t){
tt[j]=c[i].t+c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
a[i].st=c[i].t;
++tans[j];
sew=1;
break;
}
if(tt[j]<mn){
mn=tt[j];
pos=j;
}
}
if(sew)
continue;
if(table[pos]&&tt[pos]<21*3600){
while(a[vipid[cntt]].t)
++cntt;
if(cntt<=cnt&&c[vipid[cntt]].t<=tt[pos]){
a[vipid[cntt]].st=tt[pos];
tt[pos]+=c[vipid[cntt]].pt;
a[vipid[cntt]].s=c[vipid[cntt]].s;
a[vipid[cntt]].t=c[vipid[cntt]].t;
--i;
++tans[pos];
++cntt;
}
else{
a[i].st=tt[pos];
tt[pos]+=c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
++tans[pos];
}
}
else if(tt[pos]<21*3600){
a[i].st=tt[pos];
tt[pos]+=c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
++tans[pos];
}
}
sort(a+1,a+1+n,cmp2);
for(int i=1;i<=n;++i){
if(!a[i].t)
continue;
cout<<a[i].s<<" ";
int temp=a[i].st;
anss[i][0]=a[i].st/36000+'0';
a[i].st%=36000;
anss[i][1]=a[i].st/3600+'0';
a[i].st%=3600;
anss[i][2]=':';
anss[i][3]=a[i].st/600+'0';
a[i].st%=600;
anss[i][4]=a[i].st/60+'0';
a[i].st%=60;
anss[i][5]=':';
anss[i][6]=a[i].st/10+'0';
a[i].st%=10;
anss[i][7]=a[i].st+'0';
cout<<anss[i]<<" ";
int x=(temp-a[i].t)/60;
if((temp-a[i].t)%60>=30)
++x;
cout<<x<<"\n";
}
for(int i=1;i<=sum;++i)
cout<<tans[i]<<((i==sum)?"":" ");
return 0;
}

Guess you like

Origin www.cnblogs.com/ldudxy/p/11479073.html