当前位置:网站首页>2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
2022-07-06 04:43:00 【Zqchang】
官方题解
7-1 冒险者分队
分数 20
7-1 冒险者分队
一个莫名其妙的思维
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
// const int N =
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int a, b, c, x, y, z;
signed main()
{
fast;
int t;
cin >> t;
while(t --)
{
cin >> a >> b >> c >> x >> y >> z;
if(a == x && b == y && c == z)
{
cout<<0<<endl;
continue;
}
int xx = x - a;
int yy = y - b;
int zz = z - c;
if((xx + yy + zz) || (xx % 20 != 0 || yy % 20 != 0 || zz % 20)) cout << -1 << endl;
else
{
int p[3] = {
xx, yy, zz};
sort(p, p + 3);
xx = p[0] / 20, yy = p[1] / 20, zz = p[2] / 20;
int ans = 0;
if((xx % 3 + 3) % 3 != (yy % 3 + 3) % 3 || (xx % 3 + 3) % 3 != (zz % 3 + 3) % 3)
{
cout<<-1<<endl;
continue;
}
// cout << xx << " " << yy << " " << zz << endl;
if(yy > 0)
{
ans += yy;
xx += 2 * yy;
zz -= yy;
yy = 0;
ans += zz / 3 * 2;
/* while(yy > 0) { xx += 2; yy -= 1; zz -= 1; ans ++; } while(xx < 0) { xx += 3; zz -= 3; ans += 2; } */
}
else if(yy < 0)
{
ans += abs(yy);
xx += abs(yy);
zz -= 2 * abs(yy);
yy = 0;
ans += zz / 3 * 2;
/* while(yy < 0) { xx += 1; yy += 1; zz -= 2; ans ++; } while(xx < 0) { xx += 3; zz -= 3; ans += 2; } */
}
else
{
ans += zz / 3 * 2;
// while(xx < 0)
// {
// xx += 3;
// zz -= 3;
// ans += 2;
// }
}
cout << ans << endl;
}
}
return 0;
}
7-2 拼题A打卡奖励
分数 25
7-2 拼题A打卡奖励
01背包的变形,在面临超时的情况下,明智的选择另一种作为限制
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 1e3 + 10, M = 3e4 + 10;
int n, m;
int w[N], v[N];
int f[M];
signed main()
{
fast;
cin >> n >> m;
for(int i=1; i<=n; i++) cin >> v[i];//时间
for(int i=1; i<=n; i++) cin >> w[i];//金币
memset(f, 0x3f, sizeof f);
f[0] = 0;
for(int i=1; i<=n; i++)
for(int j=30000; j>=w[i]; j--)
{
f[j] = min(f[j], f[j - w[i]] + v[i]);
}
for(int i=30000; i>=0; i--)
{
if(f[i] <= m)
{
cout << i << endl;
break;
}
}
return 0;
}
7-3 快递装箱
分数 25
7-3 快递装箱
大模拟,没拿到满分,就十六分,不想改了,累了
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(p) p&(-p)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 1e4 + 10;
// deque<int> a, b, c, d;
queue<PII> a, b, c;
deque<PII> d1, d;
int n, m, w1, w2, wm;
int f1[N], f2[N];
int res1, res2;
signed main()
{
// fast;
cin >> n >> wm >> w1 >> w2;
PII p;
for(int i=1; i<=n; i++)
{
while(d.size() >= 2)
{
p = d.back();
d.pop_back();
d1.push_back(p);
}
if(c.size())
{
p = c.front();
c.pop();
if(!d.size())
{
d.push_front(p);
f1[p.y] = 1;
}
else if(d.size())
{
PII q = d.front();
d.pop_front();
if(p.x + q.x <= wm && !f1[p.y]) d.push_front({
p.x + q.x, q.y});
else if((p.x + q.x > wm && !f1[p.y]) || f1[p.y])
{
if(q.x > w2) res2 ++;
else d.push_back(q);
d.push_front(p);
f1[p.y] = 1;
}
}
}
// else if(d.size() && i == n)
// {
// PII q = d.front();
// d.pop_front();
// if(q.x > w2) res2 ++;
// else d1.push_back(q);
// }
if(b.size())
{
p = b.front();
b.pop();
if(p.x > w2) res1 ++;
else c.push(p);
}
if(a.size())
{
p = a.front();
a.pop();
if(p.x > w1) f1[p.y] = 1;
b.push(p);
}
cin >> m;
if(d1.size())
{
p = d1.front();
d1.pop_front();
if(p.x + m <= wm)
{
a.push({
m + p.x, i});
f1[i] = 1;
}
else
{
d1.push_front(p);
a.push({
m, i});
}
}
else a.push({
m, i});
// cout << "di.size(): " << d1.size() << endl;
}
if(d.size())
{
p = d.front();
d.pop_front();
if(p.x > w2) res2 ++;
else d.push_front(p);
}
vector<int> v;
while(a.size())
{
p = a.front();
v.push_back(p.x);
a.pop();
// cout << "!!!" << endl;
}
while(b.size())
{
p = b.front();
v.push_back(p.x);
b.pop();
// cout << "!!!" << endl;
}
while(c.size())
{
p = c.front();
v.push_back(p.x);
c.pop();
// cout << "!!!" << endl;
}
while(d.size())
{
p = d.front();
v.push_back(p.x);
d.pop_front();
// cout << "!!!" << endl;
}
while(d1.size())
{
p = d1.front();
v.push_back(p.x);
d1.pop_front();
// cout << "!!!" << endl;
}
sort(v.begin(), v.end());
cout << res1 << " " << res2 << " " << v.size() << endl;
if(v.size() == 0) puts("None");
else
{
for(int i=0; i<v.size(); i++)
{
cout << v[i];
if(i == v.size() - 1) cout << endl;
else cout << " ";
}
}
return 0;
}
7-4 塔防游戏
分数 30
7-4 塔防游戏
头一次写二位最短路
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define PII pair<int, int>
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PIII pair<int, PII>
#define x first
#define y second
const int N = 110;
int dx[] = {
-1,1,0,0};
int dy[] = {
0,0,-1,1};//方向
struct node
{
int x, y, z;
};
int dist[N][N];
int f[110][110];
PII path[N][N];//记录僵尸路径
bool vis[N][N];
vector<node> v;//记录僵尸
int cnt[N][N];//记录走过的步数
vector<PII> p[4 * N];//记录每个僵尸的路线
int num[4 * N];//僵尸人数
map<PII, int> mp;
int now[N * 4];
int idx = 1;
int n, m, T;
int get(PII xx)
{
if(mp[xx] == 0) mp[xx] = idx++ ;//因为前面判断就是用的等于0,所以下标要从1开始
return mp[xx];
}
///*
void dij(PII u)
{
memset(dist, 0x3f, sizeof dist);
priority_queue<PIII, vector<PIII>, greater<PIII>> q;
dist[u.x][u.y] = 0;
q.push({
0, u});
while(q.size())
{
auto t = q.top();
q.pop();
if(vis[t.y.x][t.y.y]) continue;
vis[t.y.x][t.y.y] = 1;
auto tt = t.y;
for(int i=0; i<4; i++)
{
int xx = tt.x + dx[i];
int yy = tt.y + dy[i];
if(xx > n || xx < 1 || yy > m || yy < 1) continue;
if(dist[xx][yy] > dist[tt.x][tt.y] + f[xx][yy])
{
dist[xx][yy] = dist[tt.x][tt.y] + f[xx][yy];
cnt[xx][yy] = cnt[tt.x][tt.y] + 1;
path[xx][yy] = tt;
q.push({
dist[xx][yy], {
xx, yy}});
}
else if(dist[xx][yy] == dist[tt.x][tt.y] + f[xx][yy])
{
if(cnt[xx][yy] > cnt[tt.x][tt.y] + 1)
{
path[xx][yy] = tt;
q.push({
dist[xx][yy], {
xx, yy}});
}
}
}
}
}
//*/
signed main()
{
fast;
cin >> n >> m >> T;
PII start;
for(int i=0; i<=n+1; i++)
{
for(int j=0; j<=m+1; j++)
{
cin >> f[i][j];
if(i == 0 || j == 0 || i == n + 1 || j == m + 1)
{
if((i == 0 && j == 0) || (i == 0 && j == m+1) || (i == n+1 && j == 0) || (i == n+1 && j == m+1)) continue;
else v.push_back({
i, j, f[i][j]});
}
if(f[i][j] < 0) start = {
i, j};
}
}
// /*
dij(start);
// /*
for(auto i : v)
{
int id = get({
i.x, i.y});
num[id] = i.z;
PII kk;
for(int j = 0 ; j < 4 ; j++) //由僵尸边上走到地图里面去
if(i.x + dx[j] >= 1 && i.x + dx[j] <= n && i.y + dy[j] >= 1 && i.y + dy[j] <= m)
{
kk.x = i.x + dx[j] , kk.y = i.y + dy[j];
break ;
}
while(1)
{
p[id].push_back(kk);
if(kk.x == start.x && kk.y == start.y) break;//找到大本营的位置了
kk = path[kk.x][kk.y];
}
}
// /*
for(int t = 1; t <= T; t ++)
{
// memcpy()
set<PII> s;
for(auto i : v)
{
int id = get({
i.x, i.y});
if(num[id] == 0) continue;
int xx = p[id][now[id]].x;
int yy = p[id][now[id]].y;
if(f[xx][yy] > 0 && (xx != start.x || yy != start.y)) s.insert({
xx, yy});
else if(f[xx][yy] < 0 && (xx == start.x && yy == start.y)) s.insert({
xx, yy});
}
for(auto i : v)
{
int id = get({
i.x, i.y});
if(num[id] == 0) continue;
int xx = p[id][now[id]].x;
int yy = p[id][now[id]].y;
if(s.count({
xx, yy}) == 0) now[id] ++;//set中记录了哪些是炮台,所以不需要滚动数组优化
else
{
if(f[xx][yy] > 0) f[xx][yy] --;//减到0就没了,不减了,根据输出来搞得
else if(f[xx][yy] < 0) f[xx][yy]++;
num[id] --;
}
}
if(f[start.x][start.y] == 0) break;
}
// */
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cout << f[i][j];
if(j < m) cout << " ";
else cout << endl;
}
if(f[start.x][start.y] == 0) cout << "Game Over" << endl;
return 0;
}
边栏推荐
- On the solution of es8316's audio burst
- ue5 小知识 FreezeRendering 查看视锥内渲染的物体
- C. The third problem
- flink sql 能同时读多个topic吗。with里怎么写
- How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
- [NOIP2009 普及组] 分数线划定
- 也算是學習中的小總結
- Ue5 small knowledge points to enable the setting of lumen
- CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
- Visio draws Tai Chi
猜你喜欢

Visio draw fan

比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
![[05-1, 05-02, 05-03] network protocol](/img/25/2e9ccc3f31a1fd46c9ab643d48064b.jpg)
[05-1, 05-02, 05-03] network protocol

CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)

Digital children < daily question> (Digital DP)

Easyrecovery reliable and toll free data recovery computer software

How to estimate the population with samples? (mean, variance, standard deviation)

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder

English Vocabulary - life scene memory method
随机推荐
Selection of slow motion function
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
Mysql database storage engine
How to realize automatic playback of H5 video
SQL injection vulnerability (MSSQL injection)
最高法院,离婚案件判决标准
Chip debugging of es8316 of imx8mp
SharedPreferences source code analysis
npm命令--安装依赖包--用法/详解
[FreeRTOS interrupt experiment]
[05-1, 05-02, 05-03] network protocol
[detailed steps of FreeRTOS shift value for the first time]
Postman关联
Tengine kernel parameters
How to estimate the population with samples? (mean, variance, standard deviation)
[leetcode question brushing day 33] 1189 The maximum number of "balloons", 201. The number range is bitwise AND
拉格朗日插值法
word封面下划线
2328. Number of incremental paths in the grid graph (memory search)
MIT CMS. 300 session 8 – immersion / immersion