1 solutions
-
0
Guest MOD
-
0
最抽象的一集
首先声明 这的确是链表板子 但是说一个不用链表的做法 有些抽象就是了
如果输入一个字符后的光标跳到左边 我们可以认为这个字符向右移动了 同时 其对于已经排过anser它是在右边部分中的 eg:
- a |
- a c |
- a c | f
- a c d | f
- a c d s | f
- a c d s | h f | 代表光标位置
很显然的是无论再怎么添加字符 光标|总是把整个字符串分成两部分 因此可以据此将字符分成left and right两部分 最后先输出left后逆序输出right即可
Code
#include <iostream> #include <cstring> using namespace std; const long maxn=1e6+14; char a[maxn],b[maxn],L[maxn],R[maxn]; long l,r,la; int main() { cin>>a>>b; la=strlen(a); for(int i=0;i<la;i++) if(b[i]=='R') L[++l]=a[i]; else R[++r]=a[i]; for(int i=1;i<=l;i++) cout<<L[i]; for(int i=r;i>=1;i--) cout<<R[i]; return 0; }
- 1
Information
- ID
- 332
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 24
- Accepted
- 19
- Uploaded By