import java.util.ArrayList; import java.util.Scanner; public class Main1 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); //珠子的个数 int m=sc.nextInt(); //连续不能出现同一种颜色的珠子数 int c=sc.nextInt(); //颜色的种类 ArrayList<ArrayList<Integer>> arr=new ArrayList<ArrayList<Integer>>(); for(int i=0;i<n;i++){ ArrayList<Integer> list=new ArrayList<Integer>(); int k=sc.nextInt(); for(int j=0;j<k;j++){ list.add(sc.nextInt()); } arr.add(list); } f(arr,n,m,c); } } private static void f(ArrayList<ArrayList<Integer>> arr, int n, int m, int c) { if(m==1){ System.out.println(0); return; } ArrayList<ArrayList<Integer>> p=new ArrayList<ArrayList<Integer>>(); int sum=0; for(int i=1;i<=c;i++){   //每一种颜色进行判断      ArrayList<Integer> list=new ArrayList<Integer>();      int count=1;      for(ArrayList<Integer> t:arr){      for(int j=0;j<t.size();j++){      if(t.get(j)==i){      list.add(count);      t.remove(Integer.valueOf(i));      }      }      count++;      }      p.add(list); } for(ArrayList<Integer> t:p){ if(t.size()==1){ continue; } if((t.get(0)==1)&&(t.get(t.size()-1)==n)){ sum++; continue; } for(int i=1;i<t.size();i++){ if((t.get(i)-t.get(i-1))<m){ sum++; continue; } } } System.out.println(sum); } }
点赞 1

相关推荐

七牛云头号黑子:人家是过度包装被看出来没过简历,你是包都不包啊兄弟
点赞 评论 收藏
分享
02-01 12:05
复旦大学 Java
腾讯的提前批大概率应该是没有笔试的,但是这个时候有相当部分的同学简历估计都没有准备好,没准备好的同学也不用急,大部分都是3月之后开,这个时候开的绝大多数都是神仙打架,问的东西也比较难,打算投递的同学也多看下计算机网络和操作系统,腾讯对这部分的知识问的比较多。另外多刷下牛客的热门题库,刷题注意刷ACM模式,和牛客的周赛题,腾讯有的部门会从这里面出原题。我是@程序员花海关注我,带你了解更多校招资讯!
程序员花海:还没有来得及准备的同学可以看下学习路线:https://www.nowcoder.com/discuss/824693499982315520?sourceSSR=users算法题:https://www.nowcoder.com/feed/main/detail/20e7a999fa04485b88340a274411ca0d?sourceSSR=users八股文:https://www.nowcoder.com/discuss/833102362771251200?sourceSSR=users简历书写方式:https://www.nowcoder.com/discuss/839907820706205696?sourceSSR=users都是以前在牛客发的文章~
软开人,秋招你打算投哪些...
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务