0% found this document useful (0 votes)
20 views

Problem - 1418G - Codeforces

codeforces
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Problem - 1418G - Codeforces

codeforces
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

12/21/24, 9:12 PM Problem - 1418G - Codeforces


Enter | Register

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

Educational Codeforces Round 95


G. Three Occurrences (Rated for Div. 2)

time limit per test: 5 seconds Finished


memory limit per test: 512 megabytes
→ Virtual participation 
You are given an array a consisting of n integers. We denote the subarray a[l. . r] as the array
[al , al+1 , … , ar ] (1 ≤ l ≤ r ≤ n ). Virtual contest is a way to take part in past
contest, as close as possible to participation
on time. It is supported only ICPC mode for
A subarray is considered good if every integer that occurs in this subarray occurs there exactly virtual contests. If you've seen these
thrice. For example, the array [1, 2, 2, 2, 1, 1, 2, 2, 2] has three good subarrays: problems, a virtual contest is not for you -
solve these problems in the archive. If you
just want to solve some problem from a
a[1..6] = [1, 2, 2, 2, 1, 1] ; contest, a virtual contest is not for you -
solve this problem in the archive. Never use
a[2..4] = [2, 2, 2] ; someone else's code, read the tutorials or
a[7..9] = [2, 2, 2] . communicate with other person during a
virtual contest.

Calculate the number of good subarrays of the given array a.


Start virtual contest

Input
The first line contains one integer n (1
5
≤ n ≤ 5 ⋅ 10 ).
→ Problem tags
The second line contains n integers a1 , a2 , ..., an (1 ≤ ai ≤ n ).
data structures divide and conquer
Output hashing two pointers *2500
Print one integer — the number of good subarrays of the array a. No tag edit access

Examples
→ Contest materials
input Copy

9 Announcement
1 2 2 2 1 1 2 2 2
Tutorial #1
output Copy
Tutorial #2 (en)
3

input Copy

10
1 2 3 4 1 2 3 1 2 3

output Copy

input Copy

12
1 2 3 4 3 4 2 1 3 4 2 1

output Copy

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Dec/21/2024 20:58:46UTC+5.5 (k2).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://codeforces.com/problemset/problem/1418/G 1/1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy