当前位置:网站首页>AtCoder Beginner Contest 257
AtCoder Beginner Contest 257
2022-06-30 22:20:00 【Chels.】
D - Jumping Takahashi 2
Title Description :
On a two-dimensional plane there is n A trampoline , Each trampoline has an elastic value
p, You have an initial jumping abilityS, The condition for jumping from one point to another is P i ∗ S > = ∣ x i − x j ∣ + ∣ y i − y j ∣ P_i * S >= |x_i-x_j|+|y_i - y_j| Pi∗S>=∣xi−xj∣+∣yi−yj∣ask
SWhen the minimum is , Satisfaction can make starting from any point , Can reach any other point
Ideas :
According to the above formula , It's not hard to find out S > = ⌈ ∣ x i − x j ∣ + ∣ y i − y j ∣ p i ⌉ S >= \lceil{\frac{|x_i-x_j|+|y_i-y_j|}{p_i}}\rceil S>=⌈pi∣xi−xj∣+∣yi−yj∣⌉
We can use this , As the distance between two points , run
floyedMaintain the maximum weight on the shortest path , Enumerate each point as the starting point , Find the maximum value of the path from each point to other points , Take a minimumOr you can split the answer , then dfs Explosive search , But I think this method is too complicated to write
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define inf 0x3f3f3f3f
#define mod 998244353
#define m_p(a,b) make_pair(a, b)
#define mem(a,b) memset((a),(b),sizeof(a))
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef pair <int,int> pii;
#define MAX 300000 + 50
ll n, m, k, op, x;
struct ran{
ll x, y;
ll p;
}tr[MAX];
ll dis[205][205];
void work(){
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> tr[i].x >> tr[i].y >> tr[i].p;
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
dis[i][j] = (abs(tr[i].x - tr[j].x) + abs(tr[i].y - tr[j].y) + tr[i].p - 1) / tr[i].p;
}
}
for(int k = 1; k <= n; ++k){
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
dis[i][j] = min(dis[i][j], max(dis[i][k] , dis[k][j]));
}
}
}
ll ans = 1e18;
for(int i = 1; i <= n; ++i){
ll cnt = 0;
for(int j = 1; j <= n; ++j){
cnt = max(cnt, dis[i][j]);
}
ans = min(ans, cnt);
}
cout << ans << endl;
}
int main(){
io;
work();
return 0;
}
E - Addition and Multiplication 2
Title Description :
You have now
nelement , You can spendc[i]Yuan , Multiply the current value by 10 + i, The initial value in hand is 0, Ask how much value you can get at most
Ideas :
Obviously, it is best to keep the length as long as possible
When the length is the longest , Let's consider choosing some that won't make the length smaller , And value
iBigger , Just be greedyLet's first determine how many numbers are output , Then enumerate which number is output each time , Enumeration starts from 9 Enumerate to 1, Judge the remaining money minus the current c[i] Whether the total length will be changed
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define inf 0x3f3f3f3f
#define mod 998244353
#define m_p(a,b) make_pair(a, b)
#define mem(a,b) memset((a),(b),sizeof(a))
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef pair <int,int> pii;
#define MAX 300000 + 50
int n, m, k, op, x;
int c[10];
void work(){
cin >> n;
for(int i = 1; i <= 9; ++i){
cin >> c[i];
}
int minx = *min_element(c + 1, c + 10);
k = n / minx;
for(int i = 1; i <= k; ++i){
for(int j = 9; j >= 1; --j){
if(n - c[j] >= minx * (k - i)){
n -= c[j];
cout << j;
break;
}
}
}
}
int main(){
io;
work();
return 0;
}
F - Teleporter Setting
Title Description :
n A little bit ,m side , The weight of each edge is 1, When there are some edge endpoints 0, It means that this edge is not fixed
Now you need to output n A digital , Indicates that all unfixed edges are connected to
iAfter going up ,1 To n One of the most short circuit
Ideas :
Because all unfixed edges are connected to the same point every time , So we can consider when we build the map , hold 0 As a special point , Normal mapping , Then we run twice bfs, Find out respectively with 1 As a starting point and with n The shortest circuit when it is the starting point , For each connection to
iThe situation of , We have two situations , One is not to take that special side , The answer is 1 To n One of the most short circuit , The other is to take a special side , At this time we can put 0 asi, There are two situations , One is 1 To i, Again from i To n, The other case is 1 To 0, Again from i To n, For these three cases, we can find a minimum value
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define inf 0x3f3f3f3f
#define mod 998244353
#define m_p(a,b) make_pair(a, b)
#define mem(a,b) memset((a),(b),sizeof(a))
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef pair <int,int> pii;
#define MAX 300000 + 50
int n, m, k, op, x, y;
vector<int>G[MAX];
int dis1[MAX];
int dis2[MAX];
void work(){
cin >> n >> m;
for(int i = 1; i <= m; ++i){
cin >> x >> y;
G[x].push_back(y);
G[y].push_back(x);
}
mem(dis1, inf);
mem(dis2, inf);
queue<int>q;
q.push(1);
dis1[1] = 0;
while(!q.empty()){
int u = q.front();q.pop();
for(auto v : G[u]){
if(dis1[v] != inf)continue;
dis1[v] = dis1[u] + 1;
q.push(v);
}
}
q.push(n);
dis2[n] = 0;
while(!q.empty()){
int u = q.front();q.pop();
for(auto v : G[u]){
if(dis2[v] != inf)continue;
dis2[v] = dis2[u] + 1;
q.push(v);
}
}
for(int i = 1; i <= n; ++i){
int ans = min(dis1[n], min(dis1[i] + dis2[0], dis1[0] + dis2[i]));
if(ans == inf)cout << -1 << ' ';
else cout << ans << ' ';
}
cout << endl;
}
int main(){
io;
work();
return 0;
}
边栏推荐
- leetcode:104. 二叉树的最大深度
- win11更新后任务栏空白怎么办? win11更新后任务栏空白卡死的解决方法
- Technical principle of decentralized exchange system development - digital currency decentralized exchange system development (illustrative case)
- 【BSP视频教程】BSP视频教程第19期:单片机BootLoader的AES加密实战,含上位机和下位机代码全开源(2022-06-26)
- The programmer's girlfriend gave me a fatigue driving test
- KVM IO performance test data
- I want to know who I need to know to open a stock account? In addition, is it safe to open a mobile account?
- 机器学习适合女生学吗?
- 腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
- AtCoder Beginner Contest 255
猜你喜欢

Analysis of PostgreSQL storage structure

Win11电脑名如何更改?Win11更改电脑名的方法

latex左侧大括号 latex中大括号多行公式

吴恩达的机器学习适合入门吗?
![[introduction to MySQL] the first conversation · first time in the](/img/73/cc85eb469384c3df94479318293c6f.png)
[introduction to MySQL] the first conversation · first time in the "database" Mainland

多线程经典案例

On several key issues of digital transformation

Why does the computer speed slow down after vscode is used for a long time?

Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

Using Obsidian with Hugo, markdown's local editing software is seamlessly connected with online
随机推荐
Domestic database disorder
顺祝老吴的聚会
How to upload binary pictures in uniapp
AtCoder Beginner Contest 257
微服務鏈路風險分析
About, Qianxin detects code vulnerabilities and XSS series solves them
B_ QuRT_ User_ Guide(33)
在启牛开的股票账户安全吗?如何申请低佣金的股票账户?
Where can I find the computer version of wechat files
Is the stock account opened in qiniu safe? How to apply for a low commission stock account?
电脑版微信文件存储在哪个文件夹可以找到
Uniapp life cycle / route jump
I want to know who I need to know to open a stock account? In addition, is it safe to open a mobile account?
Which direction should college students choose to find jobs after graduation?
Ten of the most heart piercing tests / programmer jokes, read the vast crowd, how to find?
Turn: win others' follow with practical actions
Mysql:sql overview and database system introduction | dark horse programmer
How to use filters in jfinal to monitor Druid for SQL execution?
Where can I find the computer device manager
Analyse des risques liés aux liaisons de microservices