当前位置:网站首页>2021 robocom world robot developer competition - undergraduate group (semi-finals)
2021 robocom world robot developer competition - undergraduate group (semi-finals)
2022-07-06 04:46:00 【Zqchang】
List of articles
Official explanation
7-1 Adventurer unit
fraction 20
7-1 Adventurer unit
An inexplicable thought
#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 Puzzle A Punch in reward
fraction 25
7-2 Puzzle A Punch in reward
01 The deformation of the backpack , In the face of timeout , Wisely choose another as a limitation
#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];// Time
for(int i=1; i<=n; i++) cin >> w[i];// Gold coin
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 Express packing
fraction 25
7-3 Express packing
Big simulation , Didn't get full marks , Just 16 points , Don't want to change , Tired
#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 Tower defense game
fraction 30
7-4 Tower defense game
Write two digit shortest path for the first time
#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};// Direction
struct node
{
int x, y, z;
};
int dist[N][N];
int f[110][110];
PII path[N][N];// Record the zombie path
bool vis[N][N];
vector<node> v;// Record zombies
int cnt[N][N];// Record the number of steps taken
vector<PII> p[4 * N];// Record the route of each zombie
int num[4 * N];// Number of zombies
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++ ;// Because the previous judgment is equal to 0, So the subscript should start from 1 Start
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++) // Go from the zombie to the map
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;// Found the location of the base camp
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 What is the fort recorded in , So there is no need to scroll array optimization
else
{
if(f[xx][yy] > 0) f[xx][yy] --;// Reduced to 0 It's gone , No less , According to the output
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;
}
边栏推荐
- SQL injection vulnerability (MSSQL injection)
- How does vs change the project type?
- A blog to achieve embedded entry
- Yyds dry goods inventory OSI & tcp/ip
- MPLS experiment
- After learning classes and objects, I wrote a date class
- Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
- Coreldraw2022 new version new function introduction cdr2022
- Bubble sort
- [FreeRTOS interrupt experiment]
猜你喜欢
Coreldraw2022 new version new function introduction cdr2022
canal同步mysql数据变化到kafka(centos部署)
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Postman关联
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
二叉树基本知识和例题
Easyrecovery靠谱不收费的数据恢复电脑软件
ISP学习(2)
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
acwing周赛58
随机推荐
Sentinel sliding window traffic statistics
Platformio create libopencm3 + FreeRTOS project
C'est un petit résumé de l'étude.
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Dry goods collection | Vulkan game engine video tutorial
团队协作出了问题,项目经理怎么办?
Orm-f & Q object
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
SharedPreferences source code analysis
Luogu deep foundation part 1 Introduction to language Chapter 2 sequential structure programming
English Vocabulary - life scene memory method
Ue5 small knowledge freezerendering view rendered objects in the cone
几种RS485隔离通讯的方案介绍
npm命令--安装依赖包--用法/详解
The most detailed and comprehensive update content and all functions of guitar pro 8.0
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
IPv6 comprehensive experiment
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
Crazy God said redis notes
项目经理,你会画原型嘛?项目经理需要做产品设计了?