(Winter camp) Rokua P2058 Seaport

Source: Internet
Author: User

Small k is a seaport customs officer, and many ships arrive at the harbor every day, and there are usually many passengers from different countries on board.

The small k was very interested in the ships that had arrived at the harbor, and he recorded the circumstances of each vessel arriving at the seaport in time; for the ship arriving on the first, he recorded the time of the ship's arrival Ti (unit: seconds), the number of passengers on board the Star Ki, and the nationality of each passenger x (i,1), X (i,2 k);.

Small k statistics on the N ship information, I hope you help calculate the arrival time of each ship up to 24 hours (24 hours = 86,400 seconds) All passengers arriving from the number of different countries.

Formally speaking, you need to calculate n information. For the output of article I information, you need to statistically meet ti-86400 < TP <= TI's ship p, in all X (P,J), how many different numbers are in total.

Input/output format

Input format:

The first line enters a positive integer n, indicating that the information of n ships is counted by the small K.

Next n lines, each line describes a ship's information: The first two integers ti and ki respectively indicate the time the ship arrived at the seaport and the number of passengers on board, and then ki an integer x (i,j) indicates the country of the passenger on board 7.

Ensure that the input ti is incremented, the unit is the second, indicating that the first time from the beginning of the work of K, this ship in ti seconds to reach the seaport.

Guarantee.

Which represents all the Ki's and.

Output format:

Output n lines, line I outputs an integer representing the statistics of the arrival of the first ship.

Input/Output sample Input Sample # #:
31 4 4 1 2 22 2 2 310 1 3
Sample # # of output:
344
Input Sample #:
41 4 1 2 2 33 2 2 386401 2 3 486402 1 5
Output Example #:
3334
"Analysis" because the total number of people are limited, you can consider the number of numbers as the axis, double-pointer sweep. L stop at the far left and R stops at the far right.
#include <iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>#include<string>#include<map>#include<stack>#include<queue>#include<vector>#defineINF 2e9#defineMet (b) memset (a,b,sizeof a)typedefLong Longll;using namespacestd;Const intN = 3e5+5;Const intM = 4e5+5;intN,m,k,sum,ans,cnt[n];intPeo[n],boa[n],t[n];intMain () {intL=0, r=0, st=1; scanf ("%d",&N);  for(intI=1; i<=n;i++) {scanf ("%d%d",&t[i],&Boa[i]);  for(intj=1; j<=boa[i];j++) {scanf ("%d", &peo[r+J]); Cnt[peo[r+j]]++; if(cnt[peo[r+j]]==1) ans++; } R+=Boa[i]; if(t[i]-t[st]>=86400){             for(intj=st;j<=i;j++){                if(t[i]-t[j]<86400) Break;  for(intc=l+1; c<=l+boa[j];c++) {Cnt[peo[c]]--; if(cnt[peo[c]]==0) ans--; } l+=Boa[j]; St++; }} printf ("%d\n", ans); }    return 0;}

(Winter camp) Rokua P2058 Seaport

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.