Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Codeforces Round 943/D. Permutation Game
PrevNext
CodeforcesCodeforces
Specialist
Codeforces Round 943

D. Permutation Game

Game TheoryMathNumber TheoryArray
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

Bodya and Sasha found a permutation π‘1,…,𝑝𝑛 and an array π‘Ž1,…,π‘Žπ‘›. They decided to play a well-known "Permutation game".

A permutation of length π‘› is an array consisting of π‘› distinct integers from 1 to π‘› in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4] is also not a permutation (𝑛=3 but there is 4 in the array).

Both of them chose a starting position in the permutation.

The game lasts π‘˜ turns. The players make moves simultaneously. On each turn, two things happen to each player:

  • If the current position of the player is π‘₯ his score increases by π‘Ž
  • .Then the player either stays at his current position π‘₯ or moves from π‘₯ to π‘π‘₯.

The winner of the game is the player with the higher score after exactly π‘˜ turns.

Knowing Bodya's starting position π‘ƒπ΅ and Sasha's starting position π‘ƒπ‘†, determine who wins the game if both players are trying to win.

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Codeforces Round 943
Previous ProblemNext Problem