坑点

  • 不记它难解我心头之恨……
  • 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. 最近火狐浏览器 总是“插件 adobe flash 已崩溃”

    原因和解决方案:在地址栏中输入:about:addons>在如下地方发现firefox已经在警告该插件的安全性了>选择“总不激活”

  2. 使用chrome的F12开发人员工具进行网页前端性能测试

    用chrome访问被测网站,定位到你要测试的动作所在页面或被测页面的前一页.按F12调出开发人员工具,其它的功能我就不介绍了,直接切换到性能选项卡Profiles. 点击start,生成ProFile ...

  3. tomcat 6.0 安装及配置

    前提:安装并配置好jdk 1.免安装版存放目录:D:\01Install\tomcat

  4. html制作细线表格

    关于这个细线表格的制作方法,百度一下可能就会有答案告诉你设置这几个值:给table设置border="0" cellspacing="1" bgcolor=&q ...

  5. dsu on tree(无讲解)

    CF741D. Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 分析: 最多有一个字符出现奇数次 维护某个状态下深度的最大值,注意 ...

  6. ACM学习历程——UVA540 Team Queue(队列,map:Hash)

    Description   Team Queue   Team Queue  Queues and Priority Queues are data structures which are know ...

  7. Mysql 5.7.18忘记密码

    5.7.18密码修改发生了变化,旧版的方法不再奏效. 1. ps -ef | grep mysqld,kill掉启动的mysql服务: 2. 创建/etc/my.cnf,添加: [mysqld] sk ...

  8. BZOJ3784:树上的路径

    浅谈树分治:https://www.cnblogs.com/AKMer/p/10014803.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem. ...

  9. python基础知识-列表,元组,字典

    列表(list) 赋值方法: l = [11,45,67,34,89,23] l = list() 列表的方法: #!/usr/bin/env python class list(object): & ...

  10. Eclipse简介和使用

    常用快捷键 快捷键的配置,常用快捷键: 内容提示: Alt + / 例如: System.out.println(); 语句 ,syso再按住alt 和/ 就会补全. 忘记某个类如何书写,可以写出一部 ...