Submission #6731379


Source Code Expand

#include <bits/stdc++.h>

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s;
  cin>>s;
  ll N = s.size();
  vector<ll> ans(N, 0);
  set<ll> se;

  // "RL" の組を見つける
  // 入ったら抜け出せない
  rep(i,0,N-1){
    if (s[i]=='R' && s[i+1]=='L') {
      se.insert(i);
      se.insert(i+1);
      ans[i] = ans[i+1] = 1;
    }
  }
  
  // 偶数回移動して "RL" の組にくっつける
  rep(i,0,N){
    if (se.find(i) != se.end())
      continue;
    if (s[i] ==  'R') {
      auto it = se.lower_bound(i);
      if ((*it - i)%2 == 1)
        it++;
      ans[*it]++;
    } else {
      auto it = se.lower_bound(i);
      it--;
      if ((i - *it)%2 == 1)
        it--;
      ans[*it]++;
    } 
  }
  rep(i,0,N){
    cout<<ans[i];
    if (i==N-1){
      cout<<endl;
    } else {
      cout<<" ";
    }
  }
  return 0;
}

Submission Info

Submission Time
Task D - Gathering Children
User bobuhiro11
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1017 Byte
Status AC
Exec Time 45 ms
Memory 6016 KiB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 21
AC × 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 AC 1 ms 256 KiB
sample_02 AC 1 ms 256 KiB
sample_03 AC 1 ms 256 KiB
testcase_01 AC 19 ms 2432 KiB
testcase_02 AC 18 ms 2304 KiB
testcase_03 AC 32 ms 3712 KiB
testcase_04 AC 32 ms 3712 KiB
testcase_05 AC 10 ms 1024 KiB
testcase_06 AC 13 ms 1280 KiB
testcase_07 AC 15 ms 1408 KiB
testcase_08 AC 16 ms 1408 KiB
testcase_09 AC 4 ms 512 KiB
testcase_10 AC 14 ms 1408 KiB
testcase_11 AC 45 ms 6016 KiB
testcase_12 AC 17 ms 1408 KiB
testcase_13 AC 15 ms 1408 KiB
testcase_14 AC 13 ms 1408 KiB
testcase_15 AC 13 ms 1408 KiB
testcase_16 AC 14 ms 1408 KiB
testcase_17 AC 14 ms 1408 KiB
testcase_18 AC 1 ms 256 KiB