https://vjudge.net/problem/UVA-514
大部分时间都拿去调输出格式了^^
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stack>
//#include <Eigen/Dense>
//#include <Eigen/Geometry>
//using namespace Eigen;
using namespace std;
int main()
{
int n;
while (cin >> n && n)
{
while(1)
{
vector<int> target(10000);
cin >> target[0];
if (!target[0])
{
cout << endl;
break;
}
for (int i = 1; i < n; i++)
{
cin >> target[i];
}
int i = 0;
int j = 1;
stack<int>s;
int ok = 1;
while (i < n)
{
if (target[i] == j)
{
i++;
j++;
}
else if (!s.empty() && s.top() == target[i])
{
s.pop();
i++;
}
else if (j <= n)
{
s.push(j++);
}
else
{
ok = 0;
break;
}
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
}