Codeforces-379C. New Year Ratings Change

Source: Internet
Author: User

Codeforces-379C. New Year Ratings Change


Principle = Peking University OJ1088 skiing, called memory DP, is the feeling of deep search, just make a mark while walking, use function backtracking ....

Is the data too big? Cannot open such a large array? Use Data Discretization and container map.

That is, leave a flag to mark the number of steps that have been followed. Next time you go to this place, skip the mark and stop, saving time.


5621923 Jan 5, 2014 4:15:28 20114045007 379C-New Year Ratings Change Gnu c ++ When there are already too many threads, there are already too many threads 780 MS 18900 KB

#include
 
  #include
  using namespace std;map
   
     ma;int next(int x){    if(ma.find(x)==ma.end())return x;    return ma[x]=next(ma[x]);}int main(){     int n,a;    int  i,j;    cin>>n;    for(i=0;i
    
     >a;        a=next(a);        ma[a]=a+1;        if(i)cout<<" ";        cout<
     




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.