当前位置:网站首页>Little C's Notepad
Little C's Notepad
2022-06-13 04:39:00 【whitewall_ nine】
My idea is to record each inserted string , This means that only the current status is recorded , Discard the previous state directly
This solution is modified on the basis of the previous state , At the same time, the information of the previous state is not discarded . And I lost the information of the previous status , It takes time to find the last state .
Sometimes to save time , Requires a lot of space , Record some extra information , This additional information depends on the situation
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pair
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> Vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const double pi = acos(-1.0);
inline ll ksc(ll x,ll y,ll mod)
{
ll ans = 0;
while (y) {
if (y & 1)
ans = (ans + x) %mod;
y >>= 1;
x = (x + x) %mod;
}
return ans;
}
inline ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a;
a = a * a;
b >>= 1;
}
return ans;
}
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {
return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {
return (a + b) %mod;
}
// inline ll inv (ll a) {
// return qmi(a, mod - 2);
// }
string s = "";
vector<string> a, b ;
int main () {
// ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
int t;
while(cin >> t) {
int q;
string s = "";
stack<string> str;
str.push("");
while(t --) {
int x;
cin >> x;
if (x == 1) {
string temp;
cin >> temp;
str.push(str.top() + temp);
}
else if (x == 2) {
int k;
cin >> k;
string ss = str.top();
str.push(ss.substr(0, ss.size() - k));
}
else if (x == 3) {
int k;
cin >> k;
s = str.top();
cout << s[k - 1] << endl;
}
else {
str.pop();
}
}
}
return 0;
}
边栏推荐
- Time format method on the official demo of uniapp
- PowerDesigner easy to use
- Implementation of homepage header function in PHP development blog system
- 【Flutter 問題系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 彈窗中不能二次跳轉路由問題的解决方案
- Catalan number
- Use service worker to preferentially request resources - continuous update
- C#获取WebService接口的所有可调用方法[WebMethod]
- PHP security development 15 user password modification module
- Application of dagger2 learning module (II)
- Get parameters on link
猜你喜欢
随机推荐
php安全开发15用户密码修改模块
Li Kou brush question 647 Palindrome substring
SQL notes
Collection of wrong questions in soft test -- morning questions in the first half of 2011
第007天:go语言字符串
ES6 learning
D 小红的构造题
Recommended temporary online image compression tool
如何只用4步,实现一个自定义JDBC驱动?
EMC rectification outline
【剑指Offer】面试题24.反转链表
PowerShell: because running scripts is prohibited on this system, the solution
Online audio adjustment technology summary
Read paper 20 together: spatiotemporal prediction of PM2.5 concentration by idw-blstm under different time granularity
How to implement a custom jdbc driver in only four steps?
Develop go using vscode
The processing flow of thread pool depends on the core parameters
Uni app Ali font icon does not display
是“凯撒密码”呀。(*‘▽‘*)*
【剑指Offer】面试题25.合并两个有序的链表









