题目描述
blablabla
样例
#include <iostream>
using namespace std;
const int N = 100001;
int stk[N] , tt = 0;
void push(int x)
{
stk[tt++] = x;
}
void pop()
{
--tt;
}
void empty()
{
if(tt == 0)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
void query()
{
printf("%d\n",stk[tt - 1]);
}
int main()
{
int x , M;
string s ;
scanf("%d", &M);
for(int i = 0 ; i < M ; i++)
{
cin >> s;
if(s == "push")
{
cin >> x;
push(x);
}
else if(s == "pop")
{
pop();
}
else if(s == "empty")
{
empty();
}
else
{
query();
}
}
return 0;
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla