Codeforces Round #310 (Div. 1)

Source: Internet
Author: User

A. Case of Matryoshkas

As long as the statistics and 1 connected to the number of good (1,2,3..K), not connected to disconnect, the rest of the chain, each chain to be broken, the price is the length of the chain I-1, and finally together, the cost is the number of all nodes-1

The array is 10000 FST.

1#include <cstdio>2#include <cstring>3#include <algorithm>4#include <iostream>5 using namespacestd;6 7typedefLong Longll;8 9 inta[100000+5];Ten  One intMain () { A     intN, K, TP, M; -     intAns =0, cnt =0; -scanf"%d%d", &n, &k); the      for(inti =1; I <= K; i++) { -scanf"%d", &m); -         BOOLFlag =0; -          for(intj =0; J < M; J + +) { +scanf"%d", &tp); -             if(TP = =1) { +Flag =1; Aa[1] =1; at                  for(intK =2; K <= m; k++) { -scanf"%d", &a[k]); -                 } -                  for(intK =1; K <= m; k++) { -                     if(A[k] = =k) { -cnt++; in}Else { -                          Break; to                     } +                 } -Ans + = mCNT; the                  Break; *             } $         }Panax Notoginseng         if(!flag) ans + = m1; -     } theAns + = nCNT; +printf"%d\n", ans); A     return 0; the}
View Code

Codeforces Round #310 (Div. 1)

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.