1351 I want 4444

Source: Internet
Author: User

M country has only four license plate numbers, and other people want them to be 8888,6666, 3333, etc., but Mr. L is very strange, he wants 4444 ......

M's license plate number issuing system is very simple, in order, from 0000 to 9999 a total of 10000 numbers, their cars are not much, and there may be decommissioned license plate numbers at any time also abandoned.

Now we know that we have handled K licenses, K consecutive Licenses Starting from 0000, mr. l it is quite uncomfortable. For some reason, it takes M days for him to apply for a license. as an administrator, you already know about the M-day license reservation. There are a total of P booking information, there are two types of reservation:

1. If you have an individual R to make an appointment to apply for a license today, you will be asked to give them a license from 0000;

2. If a license is to be decommissioned today, leave this position empty.

3. In the same day, we always process decommission tasks first and then new applications.

Mr. l wants to know that M days later, he wants to get a license while he is not ......


The first row contains an integer T, indicating that there are T groups of data.

The first row of each data group contains two integers, K and P, which are consistent with the topic description, where P <= 50.

Each row of the following P rows contains one of the two information formats:

X n l indicates that there are L applications on Day X, and N indicates the flag character.

X d r indicates that R is to be decommissioned on Day X, and D is a flag character to ensure that the data is valid.

Ensure that the input data appears before the input data in a small amount, but do not guarantee that D must appear before n.


After processing the p Reservation, the number 4444 is returned, but "yes" is returned. Otherwise, "no" is returned ".




Simulate questions and process data as required.

#include <stdio.h>#include<string.h>main(){int a[10000];int bannumber,opnumber;int number,te;int i,j,up;char op;int day,car;int daytemp;int sum;scanf("%d",&number);for(te=1;te<=number;te++){memset(a,0,sizeof(a));scanf("%d %d",&bannumber,&opnumber);for(i=0;i<bannumber;i++)a[i]=1;daytemp=0;        sum=0;if(opnumber==0){  if(bannumber>=4444)printf("No\n");elseprintf("Yes\n");} else {for(up=0;up<opnumber;up++){scanf("%d %c %d",&day,&op,&car);     if((daytemp==0||daytemp==day)&&op=='N') {    sum+=car; daytemp=day;      } if((daytemp==0||daytemp==day)&&op=='D') {    a[car]=0; op='A';  }          if((daytemp!=day||daytemp==0)||up==opnumber-1) {   for(j=0;j<sum;j++)         for(i=0;i<10000;i++) {        if(a[i]==0){      a[i]=1;       break;} }  daytemp=0;     if(op=='N')      sum=car; else sum=0; } if((daytemp==0||daytemp==day)&&op=='D') {    a[car]=0;  } }if(a[4444]==0)printf("Yes\n");elseprintf("No\n");}}}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.