当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
![[detailed steps of FreeRTOS shift value for the first time]](/img/73/a469eb2465bb2c5acaa4d018d3edd3.jpg)
[detailed steps of FreeRTOS shift value for the first time]

ETCD数据库源码分析——etcdserver bootstrap初始化存储

Canal synchronizes MySQL data changes to Kafka (CentOS deployment)

coreldraw2022新版本新功能介绍cdr2022

麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东

SQL injection vulnerability (MSSQL injection)

Easyrecovery reliable and toll free data recovery computer software

acwing周赛58

Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)

Programmers' position in the Internet industry | daily anecdotes
随机推荐
Postman关联
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
Dynamic programming (tree DP)
How does vs change the project type?
几种RS485隔离通讯的方案介绍
最高法院,离婚案件判决标准
Tengine kernel parameters
The underlying structure of five data types in redis
DMA use of stm32
MIT CMS. 300 session 8 – immersion / immersion
Yyds dry goods inventory OSI & tcp/ip
Postman测试报告
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
How to estimate the population with samples? (mean, variance, standard deviation)
It is also a small summary in learning
[try to hack] John hash cracking tool
The kernel determines whether peripherals are attached to the I2C address
Scala function advanced