D - LR insertion

网友投稿 844 2022-11-07

D - LR insertion

D - LR insertion

#include#include#include#include#includeusing namespace std;typedef long long ll;const int N = 2e5 + 10;int n, m;string s;int sx[N], sy[N];int x, y; vector a, b;int ans[N];void solve() { int n; string s; cin >> n >> s; reverse(s.begin(), s.end()); int now = n - 1; for (auto t : s) { if (t == 'R') a.push_back(now); else b.push_back(now); now --; } reverse(a.begin(), a.end()); for (auto t : a) cout << t << " "; cout << n << " "; for (auto t : b) cout << t << " ";}int main () { int t; t = 1; while (t --) solve(); return 0;}

通过把L和R分类看,发现分布规律,L和R的数字一定在一堆,不会交叉。之前就是在想如何处理交叉问题

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot实现发送电子邮件
下一篇:Codeforces Global Round 19
相关文章

 发表评论

暂时没有评论,来抢沙发吧~