Codeforces 190C(模拟)
坑点
- 不记它难解我心头之恨……
- WA1:不要读错题Orz,顺序是按它给定的。那就是个类似栈的东西,重点在于输出。
- 然而我输出很快就模拟对了……
- WA2:数据:1 int。我日了不看数据我真的去de模拟的bug了。
- WA3:中间栈空是非法。
- 貌似建一棵树可以迅速搞掉……擦
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int maxn = 1e5 + 5;
int n, m, cnt, flag, mark[maxn], go, last[maxn];
string s;
vector<string> v;
int p[maxn][2], x = 1;
void print(int now) {
cout << "pair<";
if (p[now][0] > 0) print(p[now][0]);
else cout << "int";
cout << ",";
if (p[now][1] > 0) print(p[now][1]);
else cout << "int";
cout << ">";
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
while (cin >> s) {
if (s == "pair") {
if (!m) {
go = ++m;
mark[go] = 0;
cnt += 2;
continue;
}
if (cnt == 0) flag = 1;
cnt++;
p[go][mark[go]] = ++m;//pair
mark[go] ^= 1;
last[m] = go;
go = m;
} else {
if (cnt == 0) flag = 1;
cnt--;
p[go][mark[go]] = -1;//int
mark[go] ^= 1;
while (go && mark[go] == 0) go = last[go];
}
}
if (m == 0 && n == 1) {//淦
cout << "int"; return 0;
}
if (cnt || flag) {
cout << "Error occurred";
} else {
print(x);
}
}
// pair pair int pair int int pair int int
Codeforces 190C(模拟)的更多相关文章
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- CodeForces - 404B(模拟题)
Marathon Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Sta ...
- Codeforces 709B 模拟
B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- CodeForces - 404A(模拟题)
Valera and X Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Codeforces 390A( 模拟题)
Inna and Alarm Clock Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64 ...
- Codeforces 452D [模拟][贪心]
题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...
- CodeForces - 796B 模拟
思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...
- CodeForces - 864C-Bus-(模拟加油站问题)
https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...
- Codeforces 709C 模拟
C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...
随机推荐
- Ubuntu更改启动内存
参考:https://superuser.com/questions/152921/how-to-boot-with-mem-1024m-argument-using-grub-ubuntu-10-0 ...
- redis持久化的方式RDB 和 AOF
redis持久化的方式RDB 和 AOF 一.对Redis持久化的探讨与理解 目前Redis持久化的方式有两种: RDB 和 AOF 首先,我们应该明确持久化的数据有什么用,答案是用于重启后的数据恢复 ...
- listen 66
Frog Species Found in Big Apple Scientists discover new species all the time—on the order of 15,000 ...
- javaScript的类型转换
1.javaScript会自动跟据期望将值进行转换,比如 2.下面表列出了一些javaScript的自动转换,其中粗体字表示了出乎意料的转换情况 3.显示的类型转换 尽管类型可以自动进行一些转换,但是 ...
- php之配置redis
Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. 配置说明:https://www.cnblogs.com/lucky-man/p/8359110.html ph ...
- python爬虫知识点总结(三)urllib库详解
一.什么是Urllib? 官方学习文档:https://docs.python.org/3/library/urllib.html 廖雪峰的网站:https://www.liaoxuefeng.com ...
- WPF ListView VisualPanel
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1"> &l ...
- 【239】◀▶IEW-Unit04
Unit 4 Youth Issues: Computer Use 1 Model1题目及范文分析 Some teenagers spend a lot of time playing compute ...
- Redux API之applyMiddleware
applyMiddleware(...middlewares) 使用包含自定义功能的 middleware 来扩展 Redux 是一种推荐的方式.Middleware 可以让你包装 store 的di ...
- Oracle数据去重
一.完全重复数据去重方法 具体思路是,首先创建一个临时表,然后将DISTINCT之后的表数据插入到这个临时表中;然后清空原表数据;再讲临时表中的数据插入到原表中;最后删除临时表. 对于表中完全重 ...