坑点

  • 不记它难解我心头之恨……
  • 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(模拟)的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  3. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  4. CodeForces - 404A(模拟题)

    Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  5. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  6. Codeforces 452D [模拟][贪心]

    题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...

  7. CodeForces - 796B 模拟

    思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...

  8. CodeForces - 864C-Bus-(模拟加油站问题)

    https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...

  9. Codeforces 709C 模拟

    C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...

随机推荐

  1. 常见css兼容问题

    链接的虚线框问题 <!-- html --> <a class="noDashedBox" href="#"><img src=& ...

  2. 【运维程序】简单的命令控制器(支持定时命令执行、重复定时任务命令和进程管理,开发这个小程序主要是为了方便管理服务进程)【个人github项目】

    一.前言: command-controller 一个运维程序,简单的命令控制器(支持定时命令执行和重复定时命令,开发这个程序主要是为了方便管理服务进程) 本来是要用python做的,但是之前做ffm ...

  3. 五 python 发送邮件

    需求: 系统中使用一个邮箱(这里用QQ)给其他邮箱发消息,用python完成,步骤如下: 1: 开启QQ邮箱的SMTP服务.设置-> 账号 2: 开启邮箱服务:这个需要手机验证,最后会给你一个授 ...

  4. VS2008 查找失效怎么办

    按Ctrl+F没有反应?   visual studio 里 查找替换 显示不出来;   还能用 让他查找个不存在的文本还会弹出找不到的提示; 就是看不到 查找替换的操作框了;   问题解决方法:   ...

  5. IOS要用到的零碎东西

    有些东西虽然不重要,但是零零碎碎会用到,就做个笔录吧: 协议中有2个关键字可以控制方法是否要实现(默认是@required),在大多数情况下, 用途在于程序员之间的交流 @required:这个方法必 ...

  6. 用python监控您的window服务

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://world77.blog.51cto.com/414605/782935 最近比较 ...

  7. Linux&nbsp;JDK1.4卸载与1.6的安装

    Linux JDK卸载与安装 一.jdk1.4卸载 Redhat Enterprise 5 中自带安装了jdk1.4,在安装jdk1.6前,把jdk1.4卸载: 1.首先查看系统自带JDK的版本: [ ...

  8. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  9. Ajax的调试错误信息的输出

    error: function(xhr, status, error) { console.log(xhr); console.log(status); console.log(error); }

  10. oracle查看监听状态

    产看状态命令:lsnrctl status 启动监听:lsnrctl start 关闭监听:lsnrctl stop LSNRCTL for 32-bit Windows: Version 10.2. ...