Garlic test competition (BCD), bcd

Source: Internet
Author: User

Garlic test competition (BCD), bcd

The question writing in the test competition won't be thrown out...


Elimination of racing cars

Time Limit: 1000 ms

Memory: 262144 KB

Racing competitions are becoming increasingly popular on Pandora planet. But their competition is not the same as we usually do: n racing cars are playing the same game on a long straight track. The speed of each racing car is 1 m/s, and the whole track is marked with coordinates every meter.

In the racing car, the racing car I starts from 0 seconds from ai to bi. After arriving at bi, the system returns the result of moving bi to ai. Cyclical.

It's also garlic! It turns out that this is a mobile phone game being played by garlic. Garlic bacteria can put down TNT in some places to blow up some cars. Because he has m problems. Question j: How many racing cars are there between xi and yi at corner?

Your task is to answer your question.

Input

The first line of the input contains two numbers: n and m (1 ≤ n, m ≤ 1000), representing the number of racing cars and the number of garlic problems.

In the next n rows, each line contains two integers: ai, bi (0 ≤ ai, bi ≤ 109, ai! = Bi), representing the start point and end point of racing car I respectively.

In the next m row, each row contains three integers, xj, yj, And tj (0 ≤ xj ≤ yj ≤ 109, 0 ≤ tj ≤ 109 ), it represents the left and right coordinate boundary of question j and the query time.

Output

The output contains a total of m rows, each of which has an integer representing the answers to the corresponding m questions.

Example 1

Input:

5 50 10 22 33 54 50 5 00 1 20 2 12 5 22 5 3

Output:

51243

Question Analysis: it is actually a big question. I am too sb. I didn't make a good analysis at the beginning, because the car is driving back and forth, and m and n are both 1e3, therefore, the system directly solves the problem online, finds the t-moment position for each racing car on the runway, and judges that the position is not within the target range. The method is to obtain the model of each type.

#include <cstdio>#include <cstring>int const MAX = 1005;int a[MAX], b[MAX];int main(){    int n, m;    while(scanf("%d %d", &n, &m) != EOF)    {        for(int i = 0; i < n; i++)            scanf("%d %d", &a[i], &b[i]);        while(m--)        {            int x, y, t;            scanf("%d %d %d", &x, &y, &t);            int ans = 0;            for(int i = 0; i < n; i++)            {                int tmp, dis = b[i] - a[i];                if((t / dis) % 2 == 0)                    tmp = a[i] + (t % dis);                else                    tmp = b[i] - (t % dis);                if(tmp <= y && tmp >= x)                    ans ++;            }            printf("%d\n", ans);        }    }}



Replacement joke

Time Limit: 1000 ms

Memory: 262144 KB

Little garlic is naughty again. This time, my sister's lab reports were poisoned.

My sister's lab report originally records the sequence from 1 to n, and any two numbers are separated by spaces. However, the space between the numbers is deleted by the garlic in qijie, and the entire sequence of numbers is changed to a number string with a length of 1 to 100 and no space in the header.

Now my sister is angry. I am asking you to write a program to restore the test data.

Input

There is a line in the input file, which is a string-experiment data that is messed up by garlic.

The length of a string is between 1 and 100.

Output

The output contains a line of raw test data-1 to n.

There is a space between any two data.

Example 1

Input:

4111109876532

Output:

4 1 11 10 9 8 7 6 5 3 2

Question Analysis: first, we can calculate the n value through the string length. When len <= 9, n = len, otherwise n = 9 + (len-9)/2, then the DFS is searched. Check the program for various scissors.

# Include <cstdio> # include <cstring> char s [105]; int num [100]; int len, n; bool flag, vis [100]; bool OK () // determine whether it is valid {bool has [100]; memset (has, false, sizeof (has); for (int I = 0; I <n; I ++) has [num [I] = true; for (int I = 1; I <= n; I ++) if (! Has [I]) return false; return true;} void DFS (int idx, int cnt) // subscript to idx, obtain the number of cnt {if (cnt + len-idx <n) // return if the remaining String Length cannot obtain n; if (flag) // returns return if (idx> = len) if the feasible solution is found. // returns {if (cnt = n & OK () flag = true; return;} num [cnt] = s [idx]-'0'; // single-digit if (! Vis [num [cnt]) // if the current number is not obtained, record it and continue searching {vis [num [cnt] = true; DFS (idx + 1, cnt + 1); if (flag) return; vis [num [cnt] = false;} if (idx <len-1) {num [cnt] = 10 * (s [idx]-'0') + s [idx + 1]-'0 '; // tens of digits if (num [cnt] <= n & num [cnt]> 9) {if (! Vis [num [cnt]) {DFS (idx + 2, cnt + 1); if (flag) return; vis [num [cnt] = false ;}}} return;} int main () {while (scanf ("% s", s )! = EOF) {flag = false; memset (vis, false, sizeof (vis); memset (num, 0, sizeof (num); len = strlen (s ); if (len> 9) n = 9 + (len-9)/2; elsen = len; DFS (0, 0); for (int I = 0; I <n-1; I ++) printf ("% d", num [I]); printf ("% d \ n ", num [n-1]) ;}}



Scammers

Time Limit: 1000 ms

Memory: 65536 KB

In view of the congested traffic conditions in our city, the Municipal Traffic Management Department decided to place an automatic parking Toll System on both sides of the road after hearing. When a vehicle enters a parking space, the system uses a camera to take a picture of the vehicle. It identifies the vehicle by recognizing the numbers and letters on the license plate, connects the vehicle information database of the vehicle management office to confirm the vehicle, and deducts fees.

This is where you can play well...

Some car owners block one or more numbers and letter sequences on the license plate when parking, to hinder the identification of the identification system, in order to avoid the payment of parking fees.

The car owner is simply using a gentle block to create a difficult world ?! Management is on the one hand, and technical solutions are king.

Such a difficult project had to be handed over to the computer lab. D. God is responsible for color recognition. E. God is responsible for model recognition. The possible range of license plates is reduced a little bit. As an intern, it is also an arduous task to screen license plate information that already exists in the vehicle database that matches the current known information. This is the first step of the project, I won't say much about the importance. Come on.

Input

The first line of the input file contains a string of 9 characters, which indicates recognition.

The recognizable characters are displayed by uppercase letters and numbers, and "*" indicates the characters that are not recognized due to occlusion.

The second line of the input file contains an integer n (1 ≤ n ≤ 1000)-the number of license information in the motor vehicle database.

The next n lines will contain the corresponding license information, one for each line.

The license information is a string of 9 Characters containing only numbers and uppercase letters. All license information must be different.

Output

The first act of the output file is an integer k (0 ≤ k ≤ n) -- number of licenses that meet the given requirements.

The next k lines output all possible license information.

Example 1

Input:

A**1MP19*4A001MP199E885EE098A111MP199KT7351TTB

Output:

2A001MP199A111MP199

Question Analysis: Small simulation.

#include <cstdio>#include <cstring>char s[1005][10], re[1005][10];int main(){    char t[10];    while(scanf("%s", t) != EOF)    {        memset(re, 0, sizeof(re));        int n;        scanf("%d", &n);        for(int i = 0; i < n; i++)            scanf("%s", s[i]);        int ans = 0;        for(int i = 0; i < n; i++)        {            int j;            for(j = 0; j < 9; j++)            {                if(t[j] == '*')                    continue;                if(t[j] != s[i][j])                    break;            }            if(j == 9)                strcpy(re[ans ++], s[i]);        }        printf("%d\n", ans);        for(int i = 0; i < ans; i++)            printf("%s\n", re[i]);    }}



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.