Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined)

Source: Internet
Author: User

  A question, water problem, judge all points is not into degrees and out of the same can be.

Question B, test instructions understand is water problem.

Question C. The other party must win at least one of the points after the score mod K. This method can be used to judge.

Problem d, construction problem, not = =.

E, test instructions is the choice of a node each time, the two sons of the same length of the chain to merge into a new chain of the same length. Ask if the end can be a straight chain, if you can output the shortest length. See the code:

1#include <stdio.h>2#include <algorithm>3#include <string.h>4#include <Set>5#include <iostream>6#include <vector>7 using namespacestd;8 Const intN = 2e5 +5;9 Ten intN,root; Onevector<int>G[n]; A intDfsintUintFA) - { -     Set<int>S; the      for(intI=0; I<g[u].size (); i++) -     { -         intv =G[u][i]; -         if(v = = FA)Continue; +         intt =DFS (v,u); -         if(t = =-1)return-1; +S.insert (t +1); A     } at     if(s.size () = =0)return 0; -     if(s.size () = =1)return*S.begin (); -     if(s.size () = =2&& FA = =-1)return*s.begin () + *S.rbegin (); -Root =u; -     return-1; - } in  - intMain () to { +CIN >>N; -      for(intI=1; i<n;i++) the     { *         intU,v; scanf"%d%d",&u,&v); $ G[u].push_back (v);Panax Notoginseng g[v].push_back (u); -     } the     intAns = DFS (1,-1); +     if(ans = =-1) ans = DFS (root,-1); A     if(ans = =-1)return 0*puts ("-1"); the      while(Ans%2==0) Ans >>=1; +printf"%d\n", ans); -     return 0; $}
E

Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined)

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.