标签:lag return cstring continue cto bug 数据 names 重点
#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
标签:lag return cstring continue cto bug 数据 names 重点
原文地址:https://www.cnblogs.com/AlphaWA/p/10952129.html