码迷,mamicode.com
首页 > 其他好文 > 详细

BZOJ 2760 JLOI 2011 小A的烦恼 模拟

时间:2014-12-05 21:18:53      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:bzoj   string库的运用   c++语法基础   jloi2011   无脑模拟   

题目大意:小A有一些烦恼,现在要求你去给他解决一下。


思路:语法基础题。


CODE:

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAX 1010
using namespace std;
 
int total,m;
string ans[MAX],name;
int cnt[MAX];
 
int main()
{
    cin >> total;
    for(int num,i = 1; i <= total; ++i) {
        cin >> num >> name;
        ans[0] += name;
        m = max(m,num);
        memset(cnt,0,sizeof(cnt));
        for(int j = 1; j <= num; ++j) {
            string temp;
            cin >> temp;
            ans[j] += temp;
            for(string::iterator it = temp.begin(); it != temp.end(); ++it)
                cnt[j] += *it == ',';
        }
        int _max = *max_element(cnt + 1,cnt + num + 1);
        for(int j = 0; j < MAX; ++j)
            for(int k = cnt[j]; k <= (i == total ? _max - 1:_max); ++k)
                ans[j] += ',';
    }
    for(int i = 0; i <= m; ++i)
        cout << ans[i] << endl;
    return 0;
}

JL的题为什么这么弱!!

BZOJ 2760 JLOI 2011 小A的烦恼 模拟

标签:bzoj   string库的运用   c++语法基础   jloi2011   无脑模拟   

原文地址:http://blog.csdn.net/jiangyuze831/article/details/41754391

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!