Submission #7439800


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

signed main() {
  string s;cin>>s;
  int n=s.size();

  vector<int> memo(n,0);
  
  bool hasL=false;
  int cnt=0,odd=0,even=0,bias,lid,rid;
  for(int i=0;i<=n;++i){
    if (i==n || hasL && s[i]=='R'){
      if ((cnt+bias)%2==0) {
        memo[rid] = even;
        memo[lid] = odd;
      }else{
        memo[rid] = odd;
        memo[lid] = even;
      }
     
      odd=even=cnt=0;
      hasL=false;
    }
    if (!hasL && s[i]=='L'){
      bias = cnt;
      lid=i-1;
      rid=i;
      hasL=true;
    }
    if (cnt%2==0)
      ++odd;
    else
      ++even;
    
    ++cnt;
  }

  for(int i=0;i<n;++i){
    if (i>0) cout<<" ";
    cout<<memo[i];
  }
  cout<<endl;
  
  return 0;
}

Submission Info

Submission Time
Task D - Gathering Children
User task4233
Language C++14 (GCC 5.4.1)
Score 400
Code Size 818 Byte
Status
Exec Time 14 ms
Memory 1408 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
× 21
× 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
testcase_01 9 ms 1024 KB
testcase_02 9 ms 896 KB
testcase_03 14 ms 1408 KB
testcase_04 14 ms 1408 KB
testcase_05 9 ms 1024 KB
testcase_06 11 ms 1280 KB
testcase_07 13 ms 1408 KB
testcase_08 13 ms 1408 KB
testcase_09 4 ms 512 KB
testcase_10 13 ms 1408 KB
testcase_11 13 ms 1408 KB
testcase_12 13 ms 1408 KB
testcase_13 13 ms 1408 KB
testcase_14 13 ms 1408 KB
testcase_15 13 ms 1408 KB
testcase_16 13 ms 1408 KB
testcase_17 13 ms 1408 KB
testcase_18 1 ms 256 KB