1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,m,k,d; int contract[100010]; int status; int endtime;
int t[2][1000010],x[2][1000010],cnt[2];
void calc(char mode, int t,int x) { if(status!=0&&t>endtime) status=0; if(mode=='R') { if(t<=contract[x]) printf("B\n"); else if(status==0) contract[x]=contract[0]=t+k,printf("RWB\n"); else if(t<=contract[0]) contract[x]=contract[0],printf("RWB\n"); else printf("RB\n"); } else { if(status==0) { status=1; endtime=max(t+d-1,contract[0]+d); } else endtime+=d; } }
int main() { scanf("%d%d%d%d",&n,&m,&k,&d); memset(contract,-1,sizeof(contract)); int tt,tx; char mode; while(m--) { scanf("%s%d%d",&mode,&tt,&tx); t[mode=='W'][++cnt[mode=='W']]=tt,x[mode=='W'][cnt[mode=='W']]=tx; } int it[2]={1,1}; while(it[0]<=cnt[0]||it[1]<=cnt[1]) { while(it[1]<=cnt[1]&&t[1][it[1]]<=t[0][it[0]]) calc('W',t[1][it[1]],x[1][it[1]]),++it[1]; if(it[0]<=cnt[0]) calc('R',t[0][it[0]],x[0][it[0]]),++it[0]; } return 0; }
|