题解
2025-05-08 21:19:43
发布于:江苏
7阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int n, x, TOP;
int a[1005], b[1005], st[1005];
void push(int x) {
++TOP;
st[TOP] = x;
}
void pop() {
TOP--;
}
bool empty() {
return TOP == 0;
}
int top() {
return st[TOP];
}
void clear() {
TOP = 0;
}
int size() {
return TOP;
}
int main() {
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= a[i]; j++) {
if(b[j] == 0) push(j);
b[j] = 1;
}
if(top() == a[i]) pop();
else {
cout << "Impossible";
return 0;
}
}
cout << "Possible";
return 0;
}
简单~
这里空空如也
有帮助,赞一个