NYOJ 628 xiaoyuan is working hard

Source: Internet
Author: User

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
         
          

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.