Garlic Guest-Photosynthesis

Source: Internet
Author: User

Title Link: https://nanti.jisuanke.com/t/38

Du Bear is a learning child, he always likes to do some small experiments in life, this time du Bear want to study photosynthesis.

The experimental materials of Du bear are as follows: magical seeds, ordinary cartons and some light sources. At first, the Du bear planted the seeds evenly on the bottom of the box, which you can consider as the x-axis, where the seed is located on the x-axis. The Du bear then covered the box with cardboard and installed some light sources on the cardboard (see figure). The magical seeds will grow upward until there is no light in the case of light. Now du Bear wants to know how high each seed is at the end of the experiment.

The top is the light source, the angle between the light source and the top is 45°, the yellow part is the light, the green is the plant.

Enter the first line to give a t that represents the number of groups of test data. The first line of data for each group is three integers n,m,h (1≤n≤100,000, 0≤m≤100,000, 1≤h≤10,000), n is the number of seeds (numbering 1-n), M is the number of lights, and H indicates the height of the box. Next m line, one integer for each line, Xi, indicates the position of the first light source at the top.

For each set of test data, output n rows, and a number per line indicates the final height of the seed of the first I.

Sample input
27 1 244) 4 11234
Sample output
00121001111
Two points to find the current position before and after.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5 using namespacestd;6 7 Const intMAXN = 1e5+5;8 intX[MAXN];9 intMain ()Ten { One     intT; ACin>>T; -      while(t--) -     { the         intn,m,h; -scanf" %d%d%d",&n,&m,&h); -          for(intI=1; i<=m;i++) -         { +scanf"%d",&x[i]); -         } +Sort (x+1, x+m+1); A          for(intI=1; i<=n;i++) at         { -             intAns =0; -             intCNT = Lower_bound (x+1, x+m+1, i)-x; -             if(cnt==1&&m!=0) -             { -ans = max (ans,h-x[cnt]+i); in             } -             Else if(cnt==m+1&&m!=0) to             { +ans = max (ans,h-i+x[cnt-1]); -             } the             Else if(m!=0) *             { $Ans = max (0, Max (h-i+x[cnt-1],h-x[cnt]+i));Panax Notoginseng             } -printf"%d\n", ans); the         } +     } A     return 0; the}

Garlic Guest-Photosynthesis

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.