Submission #6693868


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

template<typename T> vector<pair<T, LL>> cc(vector<T> v) {
	vector<pair<T, LL>> a;
	inc(i, v.size()) {
		if(i == 0 || v[i] != v[i - 1]) { a.EB(v[i], 1); } else { a.back().SE++; }
	}
	return a;
}

string s;

int main() {
	cin >> s;
	int n = SI(s);
	vector<int> v;
	inc(i, n) { v.PB(s[i] == 'R' ? +1 : -1); }
	
	auto w = cc(v);
	vector<int> ans(n);
	int p = 0;
	inc(i, SI(w)) {
		if(i % 2 != 0) { continue; }
		
		p += w[i].SE;
		ans[p - 1] = ce(w[i].SE, 2) + fl(w[i + 1].SE, 2);
		ans[p    ] = fl(w[i].SE, 2) + ce(w[i + 1].SE, 2);
		p += w[i + 1].SE;
	}
	
	inc(i, n) { cout << ans[i] << (i == n - 1 ? "\n" : " "); }
	
	return 0;
}

Submission Info

Submission Time
Task D - Gathering Children
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2525 Byte
Status AC
Exec Time 14 ms
Memory 3380 KB

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 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
testcase_01 AC 9 ms 1564 KB
testcase_02 AC 9 ms 1456 KB
testcase_03 AC 14 ms 2360 KB
testcase_04 AC 14 ms 2360 KB
testcase_05 AC 9 ms 1020 KB
testcase_06 AC 11 ms 1204 KB
testcase_07 AC 13 ms 1392 KB
testcase_08 AC 13 ms 1392 KB
testcase_09 AC 4 ms 512 KB
testcase_10 AC 13 ms 1392 KB
testcase_11 AC 14 ms 3380 KB
testcase_12 AC 13 ms 1392 KB
testcase_13 AC 13 ms 1392 KB
testcase_14 AC 13 ms 1392 KB
testcase_15 AC 13 ms 1392 KB
testcase_16 AC 13 ms 1392 KB
testcase_17 AC 13 ms 1392 KB
testcase_18 AC 1 ms 256 KB