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中的某一个比已存在的人中的小,就把这个人添加到 ...
随机推荐
- 笔记:如何使用postgresql做顺序扣减库存
如何使用postgresql做顺序扣减库存 Ⅰ.废话在前面 首先这篇笔记源自于最近的一次需求,这个临时性需求是根据两份数据(库存数据以及出库数据) 算出实际库存给到业务,至于库存为什么不等于剩余库存, ...
- GO的GC辣鸡回收(一)
用户程序通过内存分配器(Allocator)在堆上申请内存,而垃圾收集器(Collector)负责回收堆上的内存空间,内存分配器和垃圾收集器共同管理程序中的堆内存空间. 基本概念 垃圾分类 语义垃圾: ...
- Shell中常用的语句
exit 完全中断脚本的执行 break 中断脚本的循环,但是会执行循环外的语句 continue 跳出本次循环,进行下一次循环 进一步了解三者的区别,有如下实验: 执行该脚本: 脚本正常运行情况: ...
- Git入门配置
1.账户注册: 无论是GitHub还是码云(下称Gitee),要使用他们,我们都需要先注册账户,已有账户的可以跳过此步骤. Gitee GitHub 2.创建仓库: a.创建远程仓库 登入Gitee后 ...
- Linux从头学12:读完这篇【特权级】文章,你就比别人更“精通”操作系统!
作 者:道哥,10+年嵌入式开发老兵,专注于:C/C++.嵌入式.Linux. 关注下方公众号,回复[书籍],获取 Linux.嵌入式领域经典书籍:回复[PDF],获取所有原创文章( PDF 格式). ...
- Markdown快捷键详解(源自狂神说Java视频,整理版)
#加空格 表示是一个标题(一级标题)回车后直接生成 例下 Markdown学习 标题: ##(两个#号)空格加标题名字即为二级标题例下 二级标题 三个#号 加标题名字即为三级标题,与二级标题等有层级关 ...
- Java 简介与安装、语法说明、数据类型
目录 Java 介绍 Java 简介 Java 语言跨平台原理 JRE 和 JDK JDK 下载/安装说明 Java 语法说明 注释 关键字 标识符 数据类型 基本数据类型 引用数据类型 隐式类型转换 ...
- PHP中使用PDO操作事务的一些小测试
关于事务的问题,我们就不多解释了,以后在学习 MySQL 的相关内容时再深入的了解.今天我们主要是对 PDO 中操作事务的一些小测试,或许能发现一些比较好玩的内容. 在 MyISAM 上使用事务会怎么 ...
- PHP匿名类的用法
在PHP7之后,PHP中加入了匿名类的特性.匿名类和匿名方法让PHP成为了更现代化的语言,也让我们的代码开发工作越来越方便.我们先来看看匿名类的简单使用. // 直接定义 $objA = new cl ...
- js不记录某个url链接历史访问,返回时不返回该链接
(function(){ var fnUrlReplace = function (eleLink) { if (!eleLink) { return; } var href = eleLink.hr ...