URAL 2046 A - The First Day at School 模拟题
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
Input
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 模拟题的更多相关文章
- 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 ...
- ural 2032 Conspiracy Theory and Rebranding (数学水题)
ural 2032 Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...
- 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 ...
- URAL 1519 Formula 1(插头DP,入门题)
Description Background Regardless of the fact, that Vologda could not get rights to hold the Winter ...
- 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 ...
- 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 ...
- Ural 1079 - Maximum
Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements: a0 ...
- ACM学习
转:ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. US ...
- (转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!
ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...
随机推荐
- delphi实现ado的高级功能
ADO是Microsoft存取通用数据源的标准引擎.ADO通过封装OLE DB而能够存取不同类型的数据,让应用程序能很方便地通过统一的接口处理各种数据库.ADO由一组COM对象组成,每一个不同的原生A ...
- MOSS 2010:Visual Studio 2010开发体验(14)——列表开发之事件接收器
转:http://boke.25k5.com/kan141919.html 通过前面几篇,我们已经完成了内容类型,列表定义,列表实例g 8h"@的开发.本篇继续讲解列表中的一个重要环节- ...
- 【转】C++ 内存分配(new,operator new)详解
本文主要讲述C++ new运算符和operator new, placement new之间的种种关联,new的底层实现,以及operator new的重载和一些在内存池,STL中的应用. 一 new ...
- Android:实现一种浮动选择菜单的效果
总结如何实现Android浮动层,主要是dialog的使用. 自定义一个类继承自Dialog类,然后在构造方法中,定义这个dialog的布局和一些初始化信息. 案例1: public class Me ...
- HDU5777 domino (BestCoder Round #85 B) 思路题+排序
分析:最终的结果肯定会分成若干个区间独立,这些若干个区间肯定是独立的(而且肯定是一边倒,左右都一样) 这样想的话,就是如何把这n-1个值分成 k份,使得和最小,那么就是简单的排序,去掉前k大的(注意l ...
- bjfu1284 判别正则表达式
做解析器做得多的我,一上来就觉得要写解析器,麻烦,于是想偷懒用java的正则表达式类Pattern直接进行判断,结果wa了,原因是这题要求的正则表达式只是真正正则表达式的一个子集.比如|12是合法正则 ...
- 《Python CookBook2》 第一章 文本 - 控制大小写 && 访问子字符串
控制大小写 任务: 将一个字符串由大写转成小写,或者泛起到而行之. 解决方案: >>> a = 'a'.upper() >>> a 'A' >>> ...
- [Web API] 如何让 Web API 统一回传格式以及例外处理
[Web API] 如何让 Web API 统一回传格式以及例外处理 前言 当我们在开发 Web API 时,一般的情况下每个 API 回传的数据型态或格式都不尽相同,如果你的项目从头到尾都是由你一个 ...
- 【Windows核心编程】VirtualAlloc 例子
// VirtualAlloc.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <Windows.h> #in ...
- JAVA与多线程开发(线程基础、继承Thread类来定义自己的线程、实现Runnable接口来解决单继承局限性、控制多线程程并发)
实现线程并发有两种方式:1)继承Thread类:2)实现Runnable接口. 线程基础 1)程序.进程.线程:并行.并发. 2)线程生命周期:创建状态(new一个线程对象).就绪状态(调用该对象的s ...