Wunder Fund Round (div. 1 + div. 2 combined)

Source: Internet
Author: User

Now the level is really not enough, only can do water problem

A. Slime Combining

Test instructions: is to give you the N 1, two the same number can be combined into a number, for example, there are two identical V, the combined value is v+1

Idea: Direct Simulation stack

1#include <iostream>2#include <algorithm>3#include <stack>4 using namespacestd;5 intnum[10000];6 intMain ()7 {8     intN;9      while(Cin >>N) {Tenstack<int>p; OneP.push (1); A      for(intI=1; i<n;++i) { -P.push (1); -         intx, y; the          while(P.size () >=2){ -x=p.top ();p. Pop (); -y=p.top ();p. Pop (); -             if(x==y) +P.push (x+1); -             Else{ + P.push (y);p. push (x); A                  Break; at             } -         } -     } -         intk=0; -          while(!P.empty ()) { -num[k++]=p.top (); in P.pop (); -         } to          for(inti=k-1; i>=0;--i) +             if(i==k-1) cout <<Num[i]; -             Elsecout <<" "<<Num[i];  thecout <<Endl; *     } $}

B. Guess the permutation

This question also thought for a long time, actually figured out is very simple

Test instructions: give you a square array of values Map[i][j]=min (A[i],a[j]), that is, the value is the smaller of the two, and array A is a sequence that allows you to restore the array A through this array of values

Idea: In each row if the number of different elements equals n, then this sequence except 0 think the other value is the number of series in the array A, the remaining as long as the 0 is changed to N.

Another way of thinking (being taught by others) is that the maximum value in each row is actually the value of the array a[i], but you need to pay attention to the n-1 N, (think)

  

1#include <iostream>2#include <cstdio>3#include <cmath>4#include <cstring>5#include <Set>6 using namespacestd;7 Const intqq= -;8 intMAP[QQ][QQ];9 intMain ()Ten {     One     Set<int>P[QQ]; A     intN;SCANF ("%d",&n); -      for(intJ,i=1; i<=n;++i) { -          for(j=1; j<=n;++j) { thescanf"%d",&map[i][j]); - P[i].insert (Map[i][j]); -         } -     } +     intans; -      for(intI=1; i<=n;++i) +         if(p[i].size () = =N) { AAns=i; Break; at         } -      for(intI=1; i<=n;++i) { -         if(i==1) -             if(map[ans][i]!=0) printf ("%d", Map[ans][i]); -             Elseprintf"%d", n); -         Else in             if(map[ans][i]!=0) printf ("%d", Map[ans][i]); -             Elseprintf"%d", n); to     } +printf"\ n"); - } the     

#include<iostream>using namespacestd;intMain () {intn,f=1; CIN>>N;  for(intI=0; i<n;i++){        intm=0;  for(intj=0; j<n;j++)    {    intx; CIN>>x; M=Max (m,x); }    if(m==n-1&&f) {f=0; M+=1; } cout<<m<<" "; }        return 0;}

    

Wunder Fund Round (div. 1 + div. 2 combined)

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.