2021.7.27--Benelux Algorithm Programming Contest 2020 补提
I Jigsaw
题目内容:


链接:https://ac.nowcoder.com/acm/contest/18454/I
来源:牛客网 You have found an old jigsaw puzzle in the attic of your house, left behind by the previous occupants. Because you like puzzles, you decide to put this one together. But before you start, you want to know whether this puzzle was left behind for a reason. Maybe it is incomplete? Maybe the box contains pieces from multiple puzzles?
If it looks like a complete puzzle, you also need to know how big your work surface needs to be. Nothing worse than having to start a jigsaw over because you started on a small table. The box does not tell you the dimensions w × h of the puzzle, but you can quickly count the three types of pieces in the box:
• Corner pieces, which touch two of the edges of the puzzle.
• Edge pieces, which touch one of the edges of the puzzle.
• Center pieces, which touch none of the edges of the puzzle.
Do these pieces add up to a complete jigsaw puzzle? If so, what was the original size of the jigsaw puzzle?
输入描述: The input consists of:
• One line containing three integers c, e, and m (0 ≤ c,e,m ≤ 10 9 ), the number of corner pieces, edge pieces, and center pieces respectively. 输出描述: If there exist numbers w and h satisfying w ≥ h ≥ 2 such that the original size of the jigsaw puzzle could have been w×h, then output a single line containing w and h. Otherwise, output “impossible”.
If there are multiple valid solutions, you may output any one of them. 示例1
输入
复制 4 8 4 输出
复制 4 4 示例2
输入
复制 4 10 14 输出
复制 impossible 示例3
输入
复制 4 12 6 输出
复制 impossible 示例4
输入
复制 4 2048 195063 输出
复制 773 255
题意:有一组拼图,分别给出角块c、边缘块e、中心块m的数量,问能否构成一个完整的拼图。若能则输出该拼图的w和h(w>=h>=2),不能则输出“impossible”
思路:题目中w和h>=2,所以角块数至少为4,还可以根据拼图经验可得出方程:w*h==c+e+m; (w-2+h-2)*2==e; (w-2)*(h-2)==m;
所以可据此得到代码:


#include<bits/stdc++.h>
using namespace std;
int main()
{
int c,e,m;
cin>>c>>e>>m;
if(c>=4){
if(e==0&&m==0){
cout<<2<<" "<<2<<endl;
return 0;
}
else if(e!=0&&m==0&&e%2==0)
{
cout<<e/2+2<<" "<<2<<endl;
return 0;
}
else{
int w,h;
int t=c+e+m;
for(w=2;w*w<=c+e+m;w++)
{
if(t%w==0)
{
h=t/w;
if((w-2+h-2)*2==e&&(w-2)*(h-2)==m)
{
if(w<h)swap(w,h);
cout<<w<<" "<<h<<endl;
return 0;
}
}
}
} }
cout<<"impossible"<<endl;
}
题目内容:


链接:https://ac.nowcoder.com/acm/contest/18454/C
来源:牛客网 You are organizing a programming competition in which the rank of a team is fifirst determined by how many problems they have solved. In case of a tie, the team with the lowest time penalty is ranked above the other. However, contrary to the BAPC, the time penalty is equal to t if the latest accepted submission was submitted in the tth minute, or 0 if no problem was solved.
For example, if team A solved their fifirst problem in the 5th minute, their second problem in the 10th minute and their third problem in the 60th minute, then their time penalty is 60. If team B also solved three problems, in the 30th, 40th and 50th minute, their time penalty is 50 and they would rank above team A.
The contest has fifinished and you would like to enter the fifinal standings. However, due to a corrupted fifile you have lost part of the scoreboard. In particular, the column indicating how many problems each team has solved is gone. You do still have the time penalties of all the teams and know that they are in the right order. You also remember how many problems the contest had. You wonder whether, given this information, it is possible to uniquely reconstruct the number of problems that each team has solved. 输入描述: The input consists of:
•One line containing two integers: n (1 ≤ n ≤ 104), the number of teams participating,and p (1 ≤ p ≤ 104), the number of contest problems.
•n lines with on line i the time score tiin minutes (0 ≤ ti ≤ 106) of the team that is ranked in the ith place.
A positive time score of t indicates that a team has submitted their last accepted submission in the tth minute. A time score of 0 indicates that a team hasn’t solved any problem.
The input always originates from a valid scoreboard. 输出描述: If it is possible to uniquely reconstruct the scores of all the teams, output n lines containing the number of problems that the ith team has solved on the ith line. Otherwise, output “ambiguous”. 示例1
输入
复制 9 3
140
75
101
120
30
70
200
0
0 输出
复制 3
2
2
2
1
1
1
0
0 示例2
输入
复制 6 3
100
40
40
50
0
0 输出
复制 ambiguous
题意:你正在组织一场编程比赛,其中一个团队的排名首先取决于他们解决了多少问题。
在平局的情况下,罚时最少的球队排在另一队之上。但是,与 BAPC 相反,如果最新接受的提交是在第 t 分钟提交的,则时间惩罚等于 t,如果没有解决问题,则时间惩罚等于 0。
比赛已结束,您想进入决赛排名。但是,由于文件损坏,您丢失了记分板的一部分。特别是,显示每个团队解决了多少问题的列不见了。你仍然有所有球队的时间处罚,并且知道他们的顺序是正确的。你还记得比赛有多少问题。您想知道,根据这些信息,是否可以唯一地重建每个团队已解决的问题数量。
输入描述: 一行包含两个整数:n (1 ≤ n ≤ 104),参赛队数,p (1 ≤ p ≤ 104),比赛题数。 • n 行,第i 行是排在第i 位的球队的时间得分tiin 分钟(0 ≤ ti ≤ 106)。 t 的正时间分数表示团队在第 t 分钟提交了他们最后一次接受的提交。时间分数为 0 表示团队没有解决任何问题。 输入始终来自有效的记分板。
输出描述: 如果可以唯一地重建所有团队的分数,则输出 n 行,其中包含第 i 行上第 i 个团队已解决的问题数。否则,输出“ambiguous”。
思路: 可以确定分数时: 1.从榜首到最后一名均为0 2. 不为0时,过题数从m到1或从m到0
不可以确定分数时: 1. 最后一名罚时为0但过题数不为0 2.最后一名罚时不为0,但过题数不为1
代码:


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,p;
cin>>n>>p;
int s[10010],v[10010],k=0;
for(int i=0;i<n;i++)
{
cin>>s[i];
if(s[i]!=0)k=1;
}
if(k==0)
{
while(n--){
cout<<0<<endl;
} }
else{
v[0]=p;
for(int i=1;i<n;i++)
{
if(s[i]<s[i-1])v[i]=--p;
else v[i]=p;
}
if((v[n-1]!=1&&s[n-1]!=0)||(v[n-1]!=0&&s[n-1]==0))//此处不要弄错
cout<<"ambiguous"<<endl;
else {
for(int i=0;i<n;i++)cout<<v[i]<<endl;
}
}
}
2021.7.27--Benelux Algorithm Programming Contest 2020 补提的更多相关文章
- Benelux Algorithm Programming Contest 2014 Final(第二场)
B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...
- 2020.3.14--训练联盟周赛 Preliminaries for Benelux Algorithm Programming Contest 2019
1.A题 题意:给定第一行的值表示m列的最大值,第m行的值表示n行的最大值,问是否会行列冲突 思路:挺简单的,不过我在一开始理解题意上用了些时间,按我的理解是输入两组数组,找出每组最大数,若相等则输出 ...
- 2020.3.21--ICPC训练联盟周赛Benelux Algorithm Programming Contest 2019
A Appeal to the Audience 要想使得总和最大,就要使最大值被计算的次数最多.要想某个数被计算的多,就要使得它经过尽量多的节点.于是我们的目标就是找到 k 条从长到短的链,这些链互 ...
- 2014 Benelux Algorithm Programming Contest (BAPC 14)E
题目链接:https://vjudge.net/contest/187496#problem/E E Excellent Engineers You are working for an agency ...
- 03.14 ICPC训练联盟周赛,Preliminaries for Benelux Algorithm Programming Contest 2019
A .Architecture 题意:其实就是想让你找到两行数的最大值,然后比较是否相同,如果相同输出'possible',不同则输出'impossible' 思路:直接遍历寻找最大值,然后比较即可 ...
- Gym -102007 :Benelux Algorithm Programming Contest (BAPC 18) (寒假自训第5场)
A .A Prize No One Can Win 题意:给定N,S,你要从N个数中选最多是数,使得任意两个之和不大于S. 思路:排序,然后贪心的选即可. #include<bits/stdc+ ...
- 计蒜客 28319.Interesting Integers-类似斐波那契数列-递推思维题 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 I)
I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个 ...
- 计蒜客 28317.Growling Gears-一元二次方程的顶点公式 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 G)
G. Growling Gears 传送门 此题为签到题,直接中学的数学知识点,一元二次方程的顶点公式(-b/2*a,(4*a*c-b*b)/4*a):直接就可以得到结果. 代码: #include& ...
- 计蒜客 28315.Excellent Engineers-线段树(单点更新、区间最值) (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 E)
先写这几道题,比赛的时候有事就只签了个到. 题目传送门 E. Excellent Engineers 传送门 这个题的意思就是如果一个人的r1,r2,r3中的某一个比已存在的人中的小,就把这个人添加到 ...
随机推荐
- centos7 Tomcat 停止服务时报错: java.net.ConnectException: 拒绝连接 (Connection refused)
2021-08-02 1.问题描述 配置完 server.xml 文件后,执行 shutdown.sh 脚本停止服务,出现以下错误 2. 解决方法 查看当前正在运行的 Java 进程号 # 找到 Ja ...
- Linux学习笔记 - Linux快捷操作及常用命令
一.快捷键 剪切光标前的内容 Ctrl + u 剪切光标至行末的内容 Ctrl + k 粘贴 Ctrl + u 或 Ctrl +k 的内容 Ctrl + y 移动光标到行末 Ctrl + e 移动光标 ...
- ABP 极简入门教程(三 权限)
此处演示为MVC项目,同样权限定义需要到Application中才能在获取API时进行权限验证 一.打开Sample.Core\Authorization\PermissionNames.cs增加授权 ...
- oh,我的老伙计,你看看这近五十个dapr视频
oh,我的老伙计,你看看这近五十个 dapr 视频.这不就是你想要的视频资料吗?快来捡走吧! 开始了,但是没完全开始 Dapr 是一个可移植的.事件驱动的运行时,它使任何开发人员能够轻松构建出弹性的. ...
- ysoserial CommonsColletions3分析(1)
CC3的利用链在JDK8u71版本以后是无法使用的,具体还是由于AnnotationInvocationHandler的readobject进行了改写. 而CC3目前有两条主流的利用链,利用Trans ...
- Linux上安装服务器监视工具,名为pyDash。
pyDash – A Web Based Linux Performance Monitoring Tool 你可以通过以下命令来判断是否已安装: pip --version # Python2.x ...
- PHP大文件读取操作
简单的文件读取,一般我们会使用 file_get_contents() 这类方式来直接获取文件的内容.不过这种函数有个严重的问题是它会把文件一次性地加载到内存中,也就是说,它会受到内存的限制.因此,加 ...
- Jmeter系列(3) - 静默压测
前言 Windows环境 简述 静默 : 脱离UI运⾏JMeter压测,用命令行方式运行性能测试脚本好处:命令运⾏更容易"搞事情"命令格式: jmeter –n –t $jmx_f ...
- Linux系列(28) - 软件包简介
软件包分类 源码包(脚本安装包) 优点 开源,如果有足够的能力,可以修改源代码: 可以自由选择所需的功能: 软件是编译安装,所以更加适合自己的系统,更加稳定.效率更高: 卸载方便: 缺点 安装过程步骤 ...
- CI框架 core
https://blog.csdn.net/admin_admin/article/details/51769805 1.扩展控制器 1.在application/core新建一个自己的控制器(MY_ ...