zoukankan      html  css  js  c++  java
  • 【codeforces 190C】STL

    【题目链接】:http://codeforces.com/problemset/problem/190/C

    【题意】

    让你根据去掉标点符号的;
    pair 以及 int这两种类型;
    确定出一种类型;
    使得它能够存得下n个int;
    输入数据保证有n个int;

    【题解】

    每一个f()调用以后,就要输入一种类型;
    如果没有输入进来;则,无解;
    输入进来了;
    则根据这个输入进来的类型;
    如果是pair,则需要再输入两个类型,调用两次f();
    答案字符串加上那些被省略的标点;
    如果输入完一个类型之后,还有输入;
    也应该输出无解;
    (给的n是没用的)

    【Number Of WA

    0

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    #define Open() freopen("F:\rush.txt","r",stdin)
    #define Close() ios::sync_with_stdio(0),cin.tie(0)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 110;
    
    string s,ans;
    
    void wujie(){
        cout <<"Error occurred"<<endl;
        exit(0);
    }
    
    void f(){
        if (cin>>s){
            ans+=s;
            if (s=="pair"){
                ans+='<';f();ans+=',';f();ans+='>';
            }
        }
        else
            wujie();
    }
    
    int main(){
        //Open();
        Close();//scanf,puts,printf not use
        //init??????
        cin >> s;
        f();
        if (cin>>s)
            wujie();
        else
            cout << ans <<endl;
        return 0;
    }
  • 相关阅读:
    分布式系统理论基础
    分布式系统理论基础
    RPC框架实现
    分布式服务协调员zookeeper
    LSM Tree存储组织结构介绍
    协程 及 libco 介绍
    回顾2013——新的旅程
    从prototype beandefinition 谈 spring 的关闭流程和 prototype 的特性
    调研 中央空调 地暖 水暖
    物联网安全设计
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626291.html
Copyright © 2011-2022 走看看