Small yuan in hard time limit: 1000 MS | memory limit: 65535 KB difficulty: 2
-
Description
-
In multimedia data processing, data compression algorithms are particularly important. After class, xiaoyuan wanted to invent a data compression algorithm. She finally came up with a method. A lot of data in multimedia data is repeated, so she wants to express the same continuous data with the number of occurrences of the data and the data itself. For example, 1 1 1 2 3 3 3 3 after compression and 3 1 1 2 5 3 (3 1 2 and 5 3 ). After thinking about it, xiaoyuan hopes to implement it using code. However, we all know that xiaoyuan is busy all day studying for postgraduate entrance exams, and cannot even find a computer. So she wants to write for her as ACMer.
-
Input
-
The input contains multiple groups of data. The number T in the first row indicates the number of input samples.
In each sample, a number M <10 ^ 7 indicates the number of numbers in this group of data, and the number M indicates the number to be compressed (the number cannot exceed the range expressed by int ).
-
Output
-
Each group of test data outputs a number pair, as described above. Separate Two numbers with a space.
-
Sample Input
-
19 1 1 1 2 3 3 3 3 3
-
Sample output
-
3 1 1 2 5 3
-
AC code: memory consumption!
-
# Include
Struct node {int m, count;} num [100001]; int main () {int n, T, I, j, a; scanf ("% d ", & T); while (T --) {scanf ("% d", & n); j = 0; num [0]. m = 0; num [0]. count = 0; for (I = 0; I
I did not expect that the output can be put into the cache first!
-
AC code:
-
#include
int main(){int n,T,i,j,a,count;scanf("%d",&T);while(T--){scanf("%d",&n);scanf("%d",&j);count=1;for(i=1;i