/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 512.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Time Exceeded ≥1100ms ≥424.0 KiB
#4 Accepted 1ms 284.0 KiB
#5 Accepted 12ms 592.0 KiB

Code

#include <stdio.h>

int main() {
    int T;                    // Declare variable for number of test cases
    scanf("%d", &T);          // Read number of test cases

    while (T--) {             // Loop T times, decrementing T after each iteration
                              // (runs while T > 0, each time T decreases by 1)
        int K;                // Declare variable for number of operations
        scanf("%d", &K);      // Read the number of operations for this test case

        char str[] = "RGB";   // Initialize string with original pen order for each test case
        char temp;            // Temporary variable to swap characters

        for (int i = 1; i <= K; i++) {  // Loop from 1 to K (for each operation)
            if (i % 2 == 1) {           // If operation number is odd
                // Odd operation: move leftmost pen to middle
                // Swap first and second characters: str[0] <-> str[1]
                temp = str[0];
                str[0] = str[1];
                str[1] = temp;
            } else {
                // Even operation: move rightmost pen to middle
                // Swap third and second characters: str[2] <-> str[1]
                temp = str[2];
                str[2] = str[1];
                str[1] = temp;
            }
        }

        printf("%s\n", str);   // Print final string after K operations for this test case
    }
    return 0;                 // End of program
}

Information

Submit By
Type
Submission
Problem
P1010 Red Green Blue
Language
C99 (GCC 13.2.0)
Submit At
2025-05-21 09:45:07
Judged At
2025-05-21 09:45:07
Judged By
Score
80
Total Time
≥1100ms
Peak Memory
≥592.0 KiB