/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Wrong Answer 1ms 332.0 KiB

Code

#include <iostream>
#include <string>

using namespace std;

int main() {
  // Initialize the string
  string S = "10";

  // Roy's move: choose index 2 and flip it
  S[2] = (S[2] == '0') ? '1' : '0';

  // Emon's move: choose index 1 and flip it
  S[1] = (S[1] == '0') ? '1' : '0';

  // Print the final string
  cout << "Final string: " << S << endl;

  // Calculate the maximum consecutive '1's
  int max_count = 0;
  int current_count = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '1') {
      current_count++;
    } else {
      max_count = max(max_count, current_count);
      current_count = 0;
    }
  }
  max_count = max(max_count, current_count);

  // Print the maximum consecutive '1's
  cout << "Maximum consecutive '1's: " << max_count << endl;

  return 0;
}

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-06 13:57:00
Judged At
2024-11-06 13:57:00
Judged By
Score
0
Total Time
1ms
Peak Memory
532.0 KiB