/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    // If Roy starts and there are more 1s, then he will always choose the index with 1, thus the max consecutive 1s is the length of the string
    if (count(s.begin(), s.end(), '1') > count(s.begin(), s.end(), '0')) {
      cout << n << endl;
    } else {
      // If Roy starts and there are more 0s, then he will always choose the index with 1, thus the max consecutive 1s is the length of the string
      if (count(s.begin(), s.end(), '1') < count(s.begin(), s.end(), '0')) {
        cout << n << endl;
      } else {
        // If Roy starts and there are equal number of 0s and 1s, then he will always choose the index with 1, thus the max consecutive 1s is the length of the string
        cout << n << 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:50:50
Judged At
2024-11-06 13:50:50
Judged By
Score
0
Total Time
23ms
Peak Memory
532.0 KiB