您的位置:首页 > 其它

Ural_1494. Monobilliards(栈)

2011-12-03 19:31 309 查看
  题意看了老半天,就是说给一个序列[1, n],看是否是(1, 2, 3, ... n),入栈以后出栈时可以得到的序列。

My Code:

View Code

#include <iostream>
#include <cstdio>

using namespace std;

const int N = 100007;

int st1
, st2
;

int main() {
//freopen("data.in", "r", stdin);

int i, top1, top2, n;
while(cin >> n) {
for(i = 0; i < n; i++) {
cin >> st2[i];
}
top1 = 0; top2 = 0;
for(i = 1; i <= n; i++) {
st1[++top1] = i;
while(top1 != 0 && st1[top1] == st2[top2]) {
--top1; ++top2;
}
}
if(top1)    cout << "Cheater";
else    cout << "Not a proof";
cout << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: