"Exercise 8-4 UVA-11491" erasing and Winning

Source: Internet
Author: User

"Link" I am the link, point me:)
Test instructions


Enter the test instructions here

Exercises


Consider deleting position i.
The first i+1 will replace the first bit.
It would be better if the first bit of i+1 was larger than the first.
Then from small to big greedy Delete, find the first a[i+1]>a[i] I.
Then every time I delete such I can be.

Code

/*1.Shoud It use long long?2.Have ever test several sample (at least therr) yourself?3.Can You promise the solution are right? At Least,the main ideal4.use the puts ("") or Putchar () or printf and such things?5.init The used array or any value?6.use error max_value?7.use scanf instead of cin/cout?8.whatch out the detail input require*//*Be sure to write the idea here and then hit the code!!!*/#include <bits/stdc++.h>using namespaceStdConst intN =1e5;intN,d,l[n+10],r[n+10];CharS[n+10];voidScintx) {intL = L[x],r = R[x];    R[l] = R; L[r] = L;}intMain () {#ifdef Local_defineFreopen ("Rush_in.txt","R", stdin);#endifIos::sync_with_stdio (0), Cin.tie (0); while(CIN >> N >> d && n && D) {cin >> (s+1); for(inti =0; I <= n;i++) l[i] = i-1, r[i] = i+1;intnow = r[0]; while(1){if(d==0) Break;intNEX = R[now]; while(NEX <= n && S[nex]<=s[now])                {now = R[now];            NEX = R[nex];            } SC (now); now = L[now];if(now==0) now = R[now];        d--; } for(inti = r[0];i!=n+1; I=r[i]) cout << s[i];    cout << Endl; }return 0;}

"Exercise 8-4 UVA-11491" erasing and Winning

Related Article

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.