Approach
Direct simulation
For Codeforces 1316C — Primitive Primes, the implementation follows the problem’s operations directly while maintaining only the state needed for the next decision.
- Translate each rule into one explicit state update.
- Maintain the invariant after every processed item.
- Return the accumulated state once all relevant input has been handled.
Code notes
- 36 lines of Go from the credited upstream file 1316C.go.
- The implementation keeps its working state in language-native values and containers.
- No explicit loop blocks detected.
Complexity
Count the number and nesting of passes over the input, then include the maintained containers in the memory estimate.
Check the problem constraints before deciding whether this complexity will pass.