Submission #3426386


Source Code Expand

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int cnt=0;
int len=0;
int now=0;
int main(){
  char s[100001];
  int re[100001];
  cin >> s;

  len = strlen(s);

  for(int i=0;i<len;i++){
    if(s[i] == 'W'){
      re[i] = 1;
    }else{
      re[i] = 0;
    }
  }

  now = re[0];

  for(int i=0;i<len;i++){

    if(now!=re[i]){
      now = (now+1)%2;
      cnt++;
      }
  }

  cout << cnt << endl;

  return 0;
}

Submission Info

Submission Time
Task C - 1D Reversi
User kayano1720
Language C++14 (GCC 5.4.1)
Score 300
Code Size 636 Byte
Status AC
Exec Time 5 ms
Memory 768 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
sample sample_01.txt, sample_02.txt, sample_03.txt
All alternate_01.txt, alternate_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, same_01.txt, same_02.txt, sample_01.txt, sample_02.txt, sample_03.txt, small_01.txt, small_02.txt, small_03.txt
Case Name Status Exec Time Memory
alternate_01.txt AC 4 ms 768 KB
alternate_02.txt AC 5 ms 768 KB
random_01.txt AC 5 ms 768 KB
random_02.txt AC 5 ms 768 KB
random_03.txt AC 5 ms 768 KB
random_04.txt AC 4 ms 768 KB
random_05.txt AC 4 ms 768 KB
same_01.txt AC 4 ms 768 KB
same_02.txt AC 4 ms 768 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
small_01.txt AC 1 ms 256 KB
small_02.txt AC 1 ms 256 KB
small_03.txt AC 1 ms 256 KB