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;
}

C Corrupted Contest

题目内容:

链接: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 补提的更多相关文章

  1. Benelux Algorithm Programming Contest 2014 Final(第二场)

    B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...

  2. 2020.3.14--训练联盟周赛 Preliminaries for Benelux Algorithm Programming Contest 2019

    1.A题 题意:给定第一行的值表示m列的最大值,第m行的值表示n行的最大值,问是否会行列冲突 思路:挺简单的,不过我在一开始理解题意上用了些时间,按我的理解是输入两组数组,找出每组最大数,若相等则输出 ...

  3. 2020.3.21--ICPC训练联盟周赛Benelux Algorithm Programming Contest 2019

    A Appeal to the Audience 要想使得总和最大,就要使最大值被计算的次数最多.要想某个数被计算的多,就要使得它经过尽量多的节点.于是我们的目标就是找到 k 条从长到短的链,这些链互 ...

  4. 2014 Benelux Algorithm Programming Contest (BAPC 14)E

    题目链接:https://vjudge.net/contest/187496#problem/E E Excellent Engineers You are working for an agency ...

  5. 03.14 ICPC训练联盟周赛,Preliminaries for Benelux Algorithm Programming Contest 2019

    A .Architecture 题意:其实就是想让你找到两行数的最大值,然后比较是否相同,如果相同输出'possible',不同则输出'impossible' 思路:直接遍历寻找最大值,然后比较即可 ...

  6. Gym -102007 :Benelux Algorithm Programming Contest (BAPC 18) (寒假自训第5场)

    A .A Prize No One Can Win 题意:给定N,S,你要从N个数中选最多是数,使得任意两个之和不大于S. 思路:排序,然后贪心的选即可. #include<bits/stdc+ ...

  7. 计蒜客 28319.Interesting Integers-类似斐波那契数列-递推思维题 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 I)

    I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个 ...

  8. 计蒜客 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& ...

  9. 计蒜客 28315.Excellent Engineers-线段树(单点更新、区间最值) (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 E)

    先写这几道题,比赛的时候有事就只签了个到. 题目传送门 E. Excellent Engineers 传送门 这个题的意思就是如果一个人的r1,r2,r3中的某一个比已存在的人中的小,就把这个人添加到 ...

随机推荐

  1. 状态码1xx-6xx的含义

    1xx (临时响应)表示临时响应并需要请求者继续执行操作的状态代码. 100 (继续) 请求者应当继续提出请求. 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分. 101 (切换协议) 请 ...

  2. Tricks

    由于本人着实有些菜,因此在此积累一些巧妙的 \(Tricks\) ,以备不时之需... 与其说是 \(Tricks\) 不如说是学习笔记?? 数学 组合数 常见的数列 斐波那契数列 图论 树论 \(P ...

  3. Appium问题解决方案(2)- AttributeError:module 'appium.webdriver' has no attribute 'Remote'

    背景 运行脚本的时候,就直接报这个错误了,然后去看了下 appium.webdriver 库 结果发现啥都没有,就知道有问题了,然后一步步排查 步骤一 检查Appium-Python-Client 和 ...

  4. adb 常用命令大全(4)- 应用管理

    查看应用列表 语法格式 adb shell pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER] ...

  5. 创建 Spring容器的三种方式

    一.src路径下打包完在war包的classes层级下 1.Spring容器创建的三种方式 创建Bean容器之后创建对象: 其中第三种使用的是BeanFactory对象 2.spring通过配置文件用 ...

  6. k8s核心资源之Pod概念&入门使用讲解(三)

    目录 1. k8s核心资源之Pod 1.1 什么是Pod? 1.2 Pod如何管理多个容器? 1.3 Pod网络 1.4 Pod存储 1.5 Pod工作方式 1.5.1 自主式Pod 1.5.2 控制 ...

  7. 我在组内的Nacos分享

    本文已收录 https://github.com/lkxiaolou/lkxiaolou 欢迎star. Nacos简介 Nacos : Naming and Configuration Servic ...

  8. docker部署rabbitmq集群

    docker版本:18.09.6 或以上 rabbitmq镜像版本:rabbitmq:3.9.5-management 一.拉镜像: docker pull rabbitmq:3.9.5-manage ...

  9. scrum项目冲刺_day02总结

    摘要:今日完成任务. 1.appUI页面完成 2.图像识别正在进行 总任务: 一.appUI页面(已完成) 二.首页功能: 1.图像识别功能 2.语音识别功能 3.垃圾搜索功能 4.相关新闻爬取 三. ...

  10. centos7.5 SVN 搭建

    第一步:通过yum命令安装svnserve,命令如下: >yum -y install subversion 此命令会全自动安装svn服务器相关服务和依赖,安装完成会自动停止命令运行 若需查看s ...