Logo
(追記) (追記ここまで)

26050번 - Patio 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB42232255.000%

문제

Cimrman wants to make a square patio floor using tiles of two colours, red and blue. The patio floor should look like this (with the colors slightly faded in time):

Figure 1: One of Cimrman’s perfect patios

More specifically, the patio must have a square shape. Tiles of one of the colours are used as the border of the square. The border must be exactly one tile thick. The tiles of the other colour are used to fill the rest of the square. Also, the side of the square must consist of at least 3 tiles.

Cimrman has a long file of square red tiles and blue tiles, the size of all tiles is the same. From this file, Cimrman is going to take some tiles to use them on the floor. Manipulating the file is clumsy, so Cimrman wants the tiles to be taken easily from the file, meaning the taken tiles have to form one contiguous subsequence in the file.

Before Cimrman starts the construction, he needs to know how many suitable subsequences of tiles are there in the file.

입력

The input consists of two lines. The first line contains integer N (1 ≤ N ≤ 2 · 105), the length of the file of tiles. The second line contains string of N characters, representing the file of tiles. Only two characters appear in the string, “X” represents a blue tile and “O” represents a red tile.

출력

Output the number of contiguous subsequences in the file from which Cimrman can construct a nice square patio floor.

제한

예제 입력 1

9
XXXOXXXXX

예제 출력 1

1

예제 입력 2

10
XOXXXXXXXX

예제 출력 2

2

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CTU Open Contest > CTU Open Contest 2022 P번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /