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 ...
 
随机推荐
- Oracle 不同故障的恢复方案
			
之前在Blog中对RMAN 的备份和恢复做了说明,刚看了下,在恢复这块还有知识点遗漏了. 而且恢复这块很重要,如果DB 真要出了什么问题,就要掌握对应的恢复方法. 所以把DB的恢复这块单独拿出来说明一 ...
 - 底部菜单栏(一) TabHost实现
			
需求:使用TabHost实现底部菜单栏: 效果图: 实现分析: 1.目录结构: 代码实现: 1.activity_main.xml <?xml version="1.0" e ...
 - 使用carrierwave出现MiniMagick::Invalid错误的解决方法
			
安装Imagemagick不能从源码安装,要从软件市场安装,否则会出现错误:MiniMagick::Invalid 使用make uninstall卸载后,重新在软件市场里安装,问题解决.
 - java多线程学习笔记——详细
			
一.线程类 1.新建状态(New):新创建了一个线程对象. 2.就绪状态(Runnable):线程对象创建后,其他线程调用了该对象的start()方法.该状态的线程位于可运行线程池中, ...
 - hdu1998 bjfu1272奇数阶幻方构造
			
这题就是一个sb题,本来很水,硬是说得很含混.奇数阶幻方构造其实有好多方法,这题既不special judge,也不说清楚,以为这样能把水题变成难题似的,简直想骂出题人. /* * Author : ...
 - bjfu1164 Parity Game
			
简单规律题.首先想到的是,若01串中1有n个,则可以通过操作,使串中1的个数变为n-1.n-2……1.0个:第2个想到的是,如果n为奇数,可以通过操作,使串中1的个数最多变为n+1,而若n为偶数,则无 ...
 - PHP 调用外部程序的几种方式
			
/* php 调用python 的代码 // 第一种: // echo passthru('C:/Python34/PY.exe D:/do.py'); // 第二种: // echo exec('C ...
 - [学习笔记] Web设计过程中该做和不该做的
			
原文网址: http://www.javascriptstyle.com/the-dos-and-donts-of-web-design -该做的: QR代码QR代码即快速响应代码,这是矩阵条形码的一 ...
 - java集合框架复习(一)
			
数组类Array是java中最基本的一个存储结构,它用于存储 一组连续的对象或一组类型相同的基本类型的数据. Array特点:效率高,但容量固定且无法动态改变, 缺点:无法判断其中存有多少元素,len ...
 - mvn deploy 报错:Return code is: 400, ReasonPhrase: Bad Request. ->
			
mvn deploy 报错:Return code is: 400, ReasonPhrase: Bad Request. -> TEST通过没有报错,但是最终部署到Nexus中时出现错误. 后 ...