Submission details
Task:Lukujono
Sender:NicholasAhman
Submission time:2025-11-19 21:12:44 +0200
Language:text
Status:READY
Result:44
Feedback
groupverdictscore
#1ACCEPTED44
Test results
testverdicttimescore
#1ACCEPTED0.00 s44details

Code

# --- 1. SETUP CONSTANTS ---
# O = 1
INCREASE O

# M = 512 ( Loop Limit )
# 457 stops in 114 steps, so 512 is plenty.
INCREASE M
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )

# F = 1 ( Run Flag )
CLEAR F
INCREASE F

# --- 2. MAIN LOOP ---
REPEAT M TIMES (

    # --- STEP A: PRINT CURRENT X ---
    REPEAT F TIMES (
        PRINT X
    )

    # --- STEP B: PING-PONG DIVISION & STOP CHECK ---
    # We calculate Q ( Quotient ), R ( Remainder )
    # We also update Z ( KeepGoing Flag ) inside the loop for free.
    
    REPEAT F TIMES (
        CLEAR Q
        CLEAR R
        CLEAR T
        CLEAR Z
        
        # Loop X times
        REPEAT X TIMES (
            # T starts at 0. Set to 1.
            INCREASE T
            
            # If R=1: We found a pair ( 2 items ).
            # Action: Q++, R=0, T=0.
            # Optimization: If we increase Q, we know X >= 2. Set Z=1.
            REPEAT R TIMES (
                INCREASE Q
                CLEAR R
                CLEAR T
                
                # Set Z to 1 to indicate we are not at 1 yet.
                CLEAR Z
                INCREASE Z
            )
            
            # If R=0: No pair yet.
            # Action: R=1, T=0.
            REPEAT T TIMES (
                INCREASE R
                CLEAR T
            )
        )

        # Update Run Flag F based on Z
        # If Z is 0 ( Q was never incremented ), X was 1. Stop.
        CLEAR F
        REPEAT Z TIMES ( INCREASE F )
        
        # --- STEP C: PARALLEL DOUBLE JUMP ---
        # Only run if we are still going ( F=1 )
        REPEAT F TIMES (
            
            # Create Even Flag ( E )
            CLEAR E
            INCREASE E
            REPEAT R TIMES ( CLEAR E )
            
            # --- CASE 1: ODD ( R=1 ) ---
            # Logic: X -> 3X+1 -> ( 3X+1 )/2
            # We want to PRINT ( 3X+1 ) and set X to ( 3X+1 )/2
            # Math: New X = 3Q + 2. Intermediate V = 6Q + 4.
            
            REPEAT R TIMES (
                CLEAR X
                CLEAR V
                
                # PARALLEL CONSTRUCTION OPTIMIZATION
                # We build X and V inside the Q loop together.
                # This avoids looping 'REPEAT X' later.
                
                REPEAT Q TIMES (
                    # Add 3 to X
                    INCREASE X
                    INCREASE X
                    INCREASE X
                    
                    # Add 6 to V
                    INCREASE V
                    INCREASE V
                    INCREASE V
                    INCREASE V
                    INCREASE V
                    INCREASE V
                )
                
                # Add the constants ( +2 to X, +4 to V )
                INCREASE X
                INCREASE X
                
                INCREASE V
                INCREASE V
                INCREASE V
                INCREASE V
                
                # Print the intermediate value
                PRINT V
            )
            
            # --- CASE 2: EVEN ( R=0 ) ---
            # Logic: X -> X / 2
            # X is simply Q.
            
            REPEAT E TIMES (
                CLEAR X
                REPEAT Q TIMES ( INCREASE X )
            )
        )
    )
)

Test details

Test 1 (public)

Verdict: ACCEPTED

input
(empty)

correct output
(empty)

user output
# --- 1. SETUP CONSTANTS ---
# O = 1
INCREASE O

# M = 512 ( Loop Limit )
...

Feedback: 443 tests processed (command limit exceeded)