作者:随缘2012天王_288 | 来源:互联网 | 2023-09-18 19:02
About~2020 2020,新的起点,一起奋进!
题目要求 P5886题目链接
分析 又是令人无语的题意表述…… 其实理解以后就觉得代码很好写: 题目无非是说,评委给一些人赞赏,我们给这些人计个数,所有评委完成之后,找一找符合指定counter数值的选手…… 多水的题啊……
用Java的话注意我是怎么写的,这题读的数据量大,Scanner会炸的,OK……
AC代码&#xff08;Java语言描述&#xff09; import java. io. BufferedReader; import java. io. IOException; import java. io. InputStreamReader; public class Main { public static void main ( String[ ] args) throws IOException { BufferedReader reader &#61; new BufferedReader ( new InputStreamReader ( System. in) ) ; String[ ] start &#61; reader. readLine ( ) . split ( " " ) ; int n &#61; Integer. parseInt ( start[ 0 ] ) , m &#61; Integer. parseInt ( start[ 1 ] ) , p &#61; Integer. parseInt ( start[ 2 ] ) ; int [ ] array &#61; new int [ m&#43; 1 ] ; for ( int i &#61; 0 ; i < n; i&#43;&#43; ) { String[ ] temp &#61; reader. readLine ( ) . split ( " " ) ; int num &#61; Integer. parseInt ( temp[ 0 ] ) ; for ( int j &#61; 0 ; j < num; j&#43;&#43; ) { array[ Integer. parseInt ( temp[ j&#43; 1 ] ) ] &#43;&#43; ; } } reader. close ( ) ; StringBuilder result &#61; new StringBuilder ( ) ; int counter &#61; 0 ; for ( int i &#61; 1 ; i <&#61; m; i&#43;&#43; ) { if ( array[ i] &#61;&#61; p) { result. append ( i) . append ( " " ) ; counter&#43;&#43; ; } } System. out. println ( counter) ; System. out. println ( result. toString ( ) . trim ( ) ) ; } }