Machine Translation (noip2010)

Source: Internet
Author: User

Analysis: this is a classic queue question, which can be implemented directly using the queue. If the data range is larger, hash can be used to determine the weight!

This can be said to be a score delivery question, but some careless students may lose points here. The main reason is that the range definition of the array is inappropriate because the space is sufficient, the data range during the exam is slightly larger. Of course, there are still some students who make mistakes in the simulation. I can only say that we must have a few more pairs of special data to ensure a full score!

var  m,n,sum:longint;  q:array[0..1000] of longint;  head,tail:longint;  procedure init;  var bo:boolean;  i,j,x:longint;  begin    readln(m,n);    head:=0;tail:=0; sum:=0;    for i:=1 to n do      begin        bo:=false;        read(x);        for j:=head+1 to   tail do          if q[j]=x then            begin   bo:=true;   break; end;        if not bo  then          begin            if  tail-head>=M then  inc(head);            inc(tail);  q[tail]:=x;inc(sum);          end      end;      writeln(sum);  end;begin  assign(input,‘translate.in‘);reset(input);  assign(output,‘translate.out‘); rewrite(output);  init;  close(input); close(output);end.
View code

 

Machine Translation (noip2010)

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.