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

Problem - 1725C - Codeforces

The document describes a problem from Codeforces involving coloring lamps arranged in a circular mirror. Pak Chanek must color N lamps using M colors while ensuring that no three lamps form a right triangle with the same color. The task is to calculate the number of valid coloring configurations, modulo 998,244,353.

Uploaded by

Yhlas Yklymow
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)
12 views

Problem - 1725C - Codeforces

The document describes a problem from Codeforces involving coloring lamps arranged in a circular mirror. Pak Chanek must color N lamps using M colors while ensuring that no three lamps form a right triangle with the same color. The task is to calculate the number of valid coloring configurations, modulo 998,244,353.

Uploaded by

Yhlas Yklymow
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/ 2

5/22/24, 12:19 PM Problem - 1725C - Codeforces

|
stdfloat | Logout

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

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

COMPFEST 14 - Preliminary Online


C. Circular Mirror Mirror (Unrated, ICPC Rules, Teams
Preferred)
time limit per test: 1 second
Finished
memory limit per test: 256 megabytes
input: standard input Practice
output: standard output

Pak Chanek has a mirror in the shape of a circle. There are N lamps on the circumference
numbered from 1 to N in clockwise order. The length of the arc from lamp i to lamp i + 1 is → Virtual participation 
Di for 1 ≤ i ≤ N − 1 . Meanwhile, the length of the arc between lamp N and lamp 1 is
DN .
→ Clone Contest to Mashup 
Pak Chanek wants to colour the lamps with M different colours. Each lamp can be coloured
with one of the M colours. However, there cannot be three different lamps such that the
colours of the three lamps are the same and the triangle made by considering the three lamps → Submit?
as vertices is a right triangle (triangle with one of its angles being exactly 90 degrees).
Language: GNU G++20 13.2 (64 bit, winlibs)
The following are examples of lamp colouring configurations on the circular mirror.
Choose
Choose File No file chosen
file:

Figure 1. an example of an incorrect


Figure 2. an example Figure 3. an example Submit
colouring because lamps 1 , 2 , and 3 form
of a correct colouring of a correct colouring
a right triangle

→ Contest materials
Before colouring the lamps, Pak Chanek wants to know the number of distinct colouring
configurations he can make. Count the number of distinct possible lamp colouring
Announcement (en)
configurations, modulo 998 244 353 .
Tutorial (en)
Input
5
The first line contains two integers N and M (1 ≤ N ≤ 3 ⋅ 10 , 2 ≤ M ≤ 3 ⋅ 105 ) — the
number of lamps in the mirror and the number of different colours used.

The second line contains N integers D1 , D2 , … , DN (1 ≤ Di ≤ 109 ) — the lengths of


the arcs between the lamps in the mirror.

Output
An integer representing the number of possible lamp colouring configurations, modulo
998 244 353 .
Examples
input Copy

4 2
10 10 6 14

output Copy

10

input Copy

1 2
10

output Copy

Note
In the first example, all correct lamp colouring configurations are [1, 1, 2, 1], [1, 1, 2, 2],
[1, 2, 1, 2], [1, 2, 2, 1], [1, 2, 2, 2], [2, 1, 1, 1], [2, 1, 1, 2], [2, 1, 2, 1], [2, 2, 1, 1], and
[2, 2, 1, 2].

https://mirror.codeforces.com/problemset/problem/1725/C 1/2
5/22/24, 12:19 PM Problem - 1725C - Codeforces

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: May/22/2024 12:17:47UTC+5 (k1).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://mirror.codeforces.com/problemset/problem/1725/C 2/2

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