A - The First Day at School
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87157#problem/A

Description

Vasya is a young and very promising android. Today is his first day at University. Vasya has very carefully studied the list of all courses on the wall near the Dean’s office and has chosen the ones to attend. Now he wants to write down his own week timetable. Help him do this.
 

Input

The first line contains an integer n that is the number of courses Vasya is going to attend (1 ≤ n ≤ 12). After that the courses are listed, each is described in two lines.
The first line of a course description contains its name. The name of the course may consist of up to five words, which are divided by exactly one space (there are no spaces before the first word and after the last one). The words consist of capital and lowercase Latin letters. The length of every word is within the range from 1 to 10.
The second line of a course description contains the day of week and the number of a lesson, when it takes place. The day of week may take one of the three values: “Tuesday”, “Thursday” и “Saturday”. The number of a lesson is an integer from 1 to 4. There are no two courses, Vasya has chosen, taking place at the same time.

Output

Output the timetable as a table of the size 4×3. The columns of the table should correspond to the three academic days: the first column — to Tuesday, the second — to Thursday, the third — to Saturday. The rows should correspond to the four classes. The width of each column should be equal to 10 characters. The height of the row of the table equals to the height of the highest of its cells. If all the cells in the row are empty then the height of the row should be equal 1 character. If some word doesn’t find room in the current line, it should be placed in the next line. The text in the cell should be aligned to top and left borders. Make the table itself using characters “-” (ASCII 45), “+” (ASCII 43) and “|” (ASCII 124).

Sample Input

9
Physics
Thursday 3
Maths
Tuesday 1
Chemistry
Thursday 1
Physical education
Saturday 2
Astronomy
Saturday 4
Urban geography
Tuesday 4
History
Saturday 1
Modeling
Thursday 2
Biology
Thursday 4

Sample Output

+----------+----------+----------+
|Maths |Chemistry |History |
+----------+----------+----------+
| |Modeling |Physical |
| | |education |
+----------+----------+----------+
| |Physics | |
+----------+----------+----------+
|Urban |Biology |Astronomy |
|geography | | |
+----------+----------+----------+

HINT

题意

模拟题,画课表

题解

注意,如果这行塞满了,就换行就好了

代码:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1) using namespace std;
string s1 = "Tuesday";
string s2 = "Thursday";
string s3 = "Saturday";
string str;
vector<string>name;
int flag[]; vector<string>vi[][]; void CHANGE()
{
int pre = ;
for(int i = ; i < str.size() ; ++ i)
{
if (str[i] == ' ' || i == str.size() - )
{
string t1;
t1.clear();
if (i == str.size() - ) i ++;
for(int k = pre ; k < i ; ++ k)
{
t1.pb(str[k]);
}
name.pb(t1);
pre = i + ;
}
}
} int main(int argc,char *argv[])
{
int n;
memset(flag,,sizeof(flag));
cin >> n ;getchar();
for(int i = ; i < n ; ++ i)
{
str.clear();
getline(cin,str);
name.clear();
CHANGE();
string day;
int r;
int c;
cin >> day >> r; getchar();
if (day == s1) c = ;
else if(day == s2) c = ;
else c = ;
int flag = ;
string tt1;
for(int j = ; j < name.size() ; ++ j)
{
if (tt1.size() + name[j].size() + flag > )
{
vi[r][c].pb(tt1);
tt1.clear();
tt1 = name[j];
flag = ;
}
else
{
if (flag == ) flag = ;
else tt1 += ' ';
tt1 += name[j];
}
}
if (tt1.size() >= ) vi[r][c].pb(tt1);
}
for(int i = ; i <= ; ++ i)flag[i] = ;
for(int i = ; i <= ; ++ i)
{
for(int j = ; j <= ; ++ j)
flag[i] = max(flag[i],(int)vi[i][j].size());
}
cout <<"+----------+----------+----------+" <<endl;
for(int i = ; i <= ; ++ i)
{
for(int t = ; t <= flag[i] ; ++ t)
{
cout << "|";
for(int j = ; j <= ; ++ j)
{
int bg = ;
if (vi[i][j].size() >= t)
{
cout << vi[i][j][t-];
bg = vi[i][j][t-].size();
}
for(int r = bg + ; r <= ; ++ r) cout << " ";
cout << "|";
}
cout << endl;
}
cout <<"+----------+----------+----------+" <<endl;
}
return ;
}

URAL 2046 A - The First Day at School 模拟题的更多相关文章

  1. URAL 1993 This cheeseburger you don't need 模拟题

    This cheeseburger you don't need 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1993 Descrip ...

  2. ural 2032 Conspiracy Theory and Rebranding (数学水题)

    ural 2032  Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...

  3. Ural 1209. 1, 10, 100, 1000... 一道有趣的题

    1209. 1, 10, 100, 1000... Time limit: 1.0 secondMemory limit: 64 MB Let's consider an infinite seque ...

  4. URAL 1519 Formula 1(插头DP,入门题)

    Description Background Regardless of the fact, that Vologda could not get rights to hold the Winter ...

  5. ural 2020 Traffic Jam in Flower Town(模拟)

    2020. Traffic Jam in Flower Town Time limit: 1.0 secondMemory limit: 64 MB Having returned from Sun ...

  6. ural 2015 Zhenya moves from the dormitory(模拟)

    2015. Zhenya moves from the dormitory Time limit: 1.0 secondMemory limit: 64 MB After moving from hi ...

  7. Ural 1079 - Maximum

    Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements: a0  ...

  8. ACM学习

    转:ACM大量习题题库   ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库.   US ...

  9. (转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!

    ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...

随机推荐

  1. $( ).focus()与$( )[0].focus()区别

    $( #id).focus()与$( #id)[0].focus()没有区别,因为id必须是唯一的.如果同一页面出现多个相同的ID(这是不符合w3c规范的),$(#id)也只会拿到第一个该ID,后面的 ...

  2. Asp.Net Core(.net内核)

    Asp.Net Core(.net内核) //----------------Day1----------------一章    Web基本原理 1节课程说明 web窗体--设计界面--加法使用Chr ...

  3. C# 委托总结

    总结 委托的本质: 委托是一种特殊的数据类型,它表示某种特定类型的函数,并且可以表示多个函数,将这些函数串联起来.使用委托就好像函数调用一样. 委托实质上是一个类,编译器会根据关键字delegate自 ...

  4. 获取apk信息工具(android SDK的aapt工具)

    aapt命令是android SDK 中的一个工具,功能强大,比如在windows平台获取apk包的信息. 使用该工具准备条件,也即获取aapt.exe文件的方式(2选1即可): 安装android ...

  5. ie对行高line-height的诡异解释

    切 游戏页面真地是要求太精细了,做按钮的时候我犯了一个错误,居然用span的内联元素的行高和padding来控制,虽然有很多好处,但是IE对 line-height的解释导致按钮经常下边会缺一小部分, ...

  6. cocos2d anchor point 锚点解析

    anchor point 究竟是怎么回事? 之所以造成不容易理解的是因为我们平时看待一个图片是 以图片的中心点 这一个维度来决定图片的位置的.而在cocos2d中决定一个 图片的位置是由两个维度 一个 ...

  7. 感知器Perceptron

    Perceptron: 1.一种基于监督的线性分类器,其特点是:1)模型简单,具有很少的学习参数:2)具有可视性,一条直线即可划分:3)基于人工神经网络的原理. 其结构图为:  2.学习的关键技术: ...

  8. OnItemClickListener 的参数详解(转)

    转载地址:http://blog.iamzsx.me/show.html?id=147001 我们在使用ListView的时候,一般都会为ListView添加一个响应事件android.widget. ...

  9. cocosbuilder学习汇总

    目前与cocos2d-x-2.14版本对应的cocosbuilder版本为cocosbuilder-3,目前为alpha-5.稳定版本为cocosbuilder2.1,但与cocos2d-x不匹配(C ...

  10. openstack【Kilo】汇总:包括20英文文档、各个组件新增功能及Kilo版部署

    OpenStack Kilo版本发布 20英文文档OpenStack Kilo版本文档汇总:各个操作系统安装部署.配置文档.用户指南等文档 Kilo版部署 openstack[Kilo]入门 [准备篇 ...