当前位置:网站首页>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;
}
边栏推荐
- 正态分布(高斯分布)
- Applet - uniapp realizes the functions of two-dimensional code picture pop-up and picture saving
- php开发16退出模块
- Uni app Ali font icon does not display
- Test question bank and online simulation test for special operation certificate of construction scaffolder (special type of construction work) in 2022
- Mysql database installation
- Message scrolling JS implementation
- [sword finger offer] interview question 24 Reverse linked list
- 2022 question bank and answers for operation certificate examination of safety production management personnel in road transport enterprises
- 小程序基础入门(黑马学习笔记)
猜你喜欢
Uni app Ali font icon does not display
C盘无损移动文件
Introduction to applet Basics (dark horse learning notes)
Express scaffold creation
How to use redis
Small program imitating Taobao Jiugong grid sliding effect
Ctfshow SQL injection (231-253)
PowerShell plus domain add computer module
Collection of wrong questions in soft test -- morning questions in the first half of 2011
Redis master-slave replication, sentinel mode, cluster
随机推荐
Internet people a few years ago vs Internet people today
Day 007: go language string
Crawler scrapy framework learning 1
Message scrolling JS implementation
Colab tutorial (super detailed version) and colab pro/pro+ evaluation
How to use redis
It's the Caesar code. (*‘▽‘*)*
PHP development 16 exit module
一致性哈希的简单认识
Uni app Ali font icon does not display
Small program input element moving up
2022 chlorination process operation certificate examination question bank and simulation examination
CTFSHOW SQL注入篇(231-253)
[untitled]
[try to hack] upload labs (temporarily write to 12)
2022年建筑架子工(建筑特殊工种)特种作业证考试题库及在线模拟考试
第三方评论插件
Vercel 使用 HTTP 缓存
Converting MySQL data to PostgreSQL with Navicat
JS, how to add grid style