坑点

  • 不记它难解我心头之恨……
  • 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. Linux_服务器_06_VMware虚拟机下安装CentOS7.0图文教程

    二.参考资料 1.VMware虚拟机下安装CentOS7.0图文教程

  2. 常见排序算法-php

    1.归并排序 $a = [1, 4, 6, 8, 10, 14, 16]; $b = [2, 3, 5, 8, 9, 11]; function merge_sort($a, $b) { $a_i = ...

  3. GIT的Push和Pull,强制Pull覆盖本地命令

    连接命令: git remote add origin + 你Git库的地址 其中,origin是你对这个Git库地址的标识. 一. 把文件从本地上传到库中 第一步:使用命令 git add命令把文件 ...

  4. docker基础用法

    docker 架构: docker 安装前期准备: 安装centos7 ,不要在centos6  [root@node01 yum.repos.d]# uname -a Linux node01 -. ...

  5. 洛谷【P2664】树上游戏

    浅谈树分治:https://www.cnblogs.com/AKMer/p/10014803.html 题目传送门:https://www.luogu.org/problemnew/show/P266 ...

  6. hdu 5730 Shell Necklace —— 分治FFT

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5730 DP式:\( f[i] = \sum\limits_{j=1}^{i} f[i-j] * a[j] ...

  7. 数据库和ADO

    数据库语言 数据库的简易流程(数据库客户端软件和数据库服务软件的执行流程) 主键的概念 如何创建主键 如何创建外键 主外键关系的概念以及使用 数据库的主要类型 数据库的主要数据类型 使用SQL语句来创 ...

  8. java计算两个时间相差(天、小时、分钟、秒)

    public static Long dateDiff(String startTime, String endTime, String format, String str) { // 按照传入的格 ...

  9. 解决Response输出时乱码

    Response ServletResponse – 通用的response提供了一个响应应该具有的最基本的属性和方法 | |- HttpServletResponse – 在ServletRespo ...

  10. Lagom学习(一)

    Lagom是JAVA系下响应式 微服务框架,其特性包括: 目前,大多数已有的微服务框架关注于简化单个微服务的构建,Lagom将其扩展到了微服务所构成的系统,分布式系统的复杂性. 同步通信使用HTTP, ...