Class(ACM ICPC 2008–2009, NEERC, Northern Subregional Contest)
来源:互联网 发布:怎样手机网络理财投资 编辑:程序博客网 时间:2024/06/05 10:10
ACM ICPC 2008–2009, NEERC, Northern Subregional ContestSt Petersburg, November 1, 2008Problem C. ClassInput file: class.inOutput file: class.outTime limit: 3 secondsMemory limit: 256 megabytesDr. Strange is a really strange lecturer. Each lecture he calculates class fullness and if it is small, hedecreases all semester grades by one. So the students want to maximize the class fullness.The class fullness is the minimum of row fullness and column fullness. The column fullness is themaximum number of students in a single column and the row fullness is the maximum number of studentsin a single row.For example there are 16 students shown on the left picture (occupied desks are darkened). The rowfullness of this arrangement is 5 (the 4-th row) and the column fullness is 3 (the 1-st, the 3-rd, the 5-th orthe 6-th columns). So, the class fullness is 3. But if the students rearrange as shown on the right picturethen the column fullness will become 4 (the 5-th column), and so the class fullness will also become 4.12341234561234123456The students of Dr. Strange need to know the arrangement that maximizes class fullness so they askyou to write a program that calculates it for them.InputThe first line of the input file contains three integer numbers: n, r and c — number of students, rowsand columns in the class (1 ≤ r, c ≤ 100, 1 ≤ n ≤ r × c).OutputThe first line of the output file must contain a single integer number — the maximum possible classfullness.The following r lines must contain the optimal student arrangement. Each line must contain a descriptionof a single row. Row description is a line of c characters either ‘‘.’’ or ‘‘#’’, where ‘‘.’’ denotes an emptydesk, and ‘‘#’’ denotes an occupied one. If there are multiple optimal arrangements, output any one.Exampleclass.in class.out16 4 6 4.####.#..####...#####.##
//// main.cpp// 160929//// Created by liuzhe on 17/3/30.// Copyright © 2016年 my_code. All rights reserved.////#include <bits/stdc++.h>#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <map>#include <set>#include <queue>#include <deque>#include <list>#include <bitset>#include <stack>using namespace std;char s[105][105];int main( ){ freopen("class.in","r",stdin); freopen("class.out","w",stdout); int n,m,a; while(cin>>a>>n>>m) { int t = min(n,m); int x = (a+1)>>1; t = min(t,x); cout<<t<<endl; for(int i=0;i<n;i++) for(int j=0;j<m;j++) s[i][j] = '.'; for(int i=0,j=0;j<m&&j<t;j++) { if(a) { s[i][j] = '#'; a--; } } if(a) { for(int j=0,i=0;i<n;i++) { if(a) { if(s[i][j]!='#') { s[i][j] = '#'; a--; } } } } for(int i=0;i<n;i++) for(int j=0;j<m;j++) { if(a&&s[i][j]!='#') { a--; s[i][j]='#'; } } for(int i=0;i<n;i++) cout<<s[i]<<endl; } return 0;}
0 0
- Class(ACM ICPC 2008–2009, NEERC, Northern Subregional Contest)
- ACM ICPC 2008–2009, NEERC, Northern Subregional Contest St Petersburg(Gym 100623)
- 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest
- 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest【9/12】
- 2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest
- 2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest
- 2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest
- ACM ICPC 2011–2012, NEERC, Northern Subregional Contest J. John’s Inversions(合并排序求逆序数对数)
- SDU省赛选拔-ACM ICPC 2010–2011, NEERC, Northern Subregional Contest
- 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D:Distribution in Metagonia(构造)
- 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest G:Graph (构造,拓扑)
- 2008-2009 ACM-ICPC, NEERC, Southern Subregional Contest
- 【2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest L】【水题】Lucky Chances (点,方向)所经权值都严格小
- 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest Problem J 【二分+DP+单调队列】
- 2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest G - Gangsters in Central City
- 2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest 组队选拔赛一
- John’s Inversions 2011-2012 ACM-ICPC, NEERC, Northern Subregional Contest
- Joy of Flight 2014-2015 ACM-ICPC, NEERC, Northern Subregional Contest
- python自己编写模块
- caffe接口及命令操作
- make Image uImage与zImage的区别
- Android入门之系统架构了解
- Jmeter性能测试 入门
- Class(ACM ICPC 2008–2009, NEERC, Northern Subregional Contest)
- 批量安装当前目录下的apk文件
- CAFFE源码学习笔记之五-internal_thread
- Ubuntu下Redis安装
- 关于用集合的remove方法删除list集合中满足条件的元素问题
- day03_从键盘输入3个数,进行排序并从大到小输出
- String,StringBuffer、StringBuilde 详细介绍
- 解决:Oracle the network adapter could not establish the connection
- 销毁Session