游戏《工程师死绝的世界》题目翻译及题解合集
游戏地址:拠点 | エンジニアが死滅シタ世界 〜アンドロイドとふたりぼっちで生きろ〜(需要 …
May all the beauty be blessed.
Translation by KSkun
原题:問題「学べない学校」 | エンジニアが死滅シタ世界 〜アンドロイドとふたりぼっちで生きろ〜
学校里的孩子们在玩剪刀石头布。特别是A君和B君,每天都要来上几盘,两人争来争去非要比个高下。
你知道了两个人的游戏记录,他们想让你写一个程序来判定他们谁最强。
A君和B君一共进行了N次游戏。
你知道了他们进行的游戏次数N以及每一次的状况,你需要写一个统计A君和B君获胜次数的程序。
剪刀石头布有三种手势:剪刀、石头、步。
石头可以赢剪刀,剪刀赢布,布赢石头。
输入中:
g表示c表示p表示样例1的说明如下图所示。

N
a_1 b_1
a_2 b_2
...
a_N b_N
以以下的格式分别输出A君和B君获胜的次数。
w_a
w_b
g、c和p中的一种。输入:
3
g g
c p
p g
输出:
2
0
输入:
10
p g
c c
p p
g g
c p
c p
g g
p p
g p
p g
输出:
4
1
// Code by KSkun, 2019/1
#include <cstdio>
#include <cctype>
#include <algorithm>
typedef long long LL;
inline char fgc() {
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
? EOF : *p1++;
}
inline LL readint() {
LL res = 0, neg = 1; char c = fgc();
for(; !isdigit(c); c = fgc()) if(c == '-') neg = -1;
for(; isdigit(c); c = fgc()) res = res * 10 + c - '0';
return res * neg;
}
inline char readsingle() {
char c;
while(!isgraph(c = fgc())) {}
return c;
}
inline int win(char a, char b) {
if(a == b) return 0;
if(a == 'g' && b == 'c') return 1;
if(a == 'c' && b == 'p') return 1;
if(a == 'p' && b == 'g') return 1;
return -1;
}
int n, cnta = 0, cntb = 0;
char wa[5], wb[5];
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
scanf("%s%s", wa, wb);
int res = win(wa[0], wb[0]);
if(res > 0) cnta++;
else if(res < 0) cntb++;
}
printf("%d\n%d\n", cnta, cntb);
return 0;
}
Translation by KSkun
原题:問題「隔離された街のゲート」 | エンジニアが死滅シタ世界 〜アンドロイドとふたりぼっちで生きろ〜
你找到了一个未完成的游戏程序,这个游戏没有实现控制角色移动的方法。
这个未完成的游戏使用宽为 W 高为 H 的网格图作为地图。
左下角的点是原点,坐标是 (0, 0) 。
从原点横向前进 x 单位,纵向前进 y 单位到达的点坐标表示为 (x, y) 。
现在由于处于开发阶段,地图上没有障碍物,角色的初始坐标为 (0, 0) 。
从该状态开始,执行总共 N 个的向上、下、左或右的移动操作。
各个移动操作对角色坐标 (x, y) 的更改情况如下所示:
在开发需求文档中,需要编写一个能够判断角色在 N 次移动操作的过程中是否处于不合法的坐标上。
这里的不合法的坐标指的是在地图之外的坐标,也就是地图上不存在的坐标。
例如,输入输出样例1和2可以表示如下。


H W N
d_1
...
d_N
在 N 次移动操作中,如果角色到达了不合法的坐标,则输出一行“invalid”,否则输出一行“valid”。
输入:
3 3 5
U
R
D
R
L
输出:
valid
输入:
4 4 7
U
U
R
R
R
R
D
输出:
invalid
// Code by KSkun, 2019/5
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
typedef long long LL;
inline char fgc() {
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
? EOF : *p1++;
}
inline LL readint() {
LL res = 0, neg = 1; char c = fgc();
for(; !isdigit(c); c = fgc()) if(c == '-') neg = -1;
for(; isdigit(c); c = fgc()) res = res * 10 + c - '0';
return res * neg;
}
inline char readsingle() {
char c;
while(!isgraph(c = fgc())) {}
return c;
}
inline bool isop(char c) {
return c == 'U' || c == 'D' || c == 'R' || c == 'L';
}
inline char readop() {
char c;
while(!isop(c = fgc())) {}
return c;
}
int n, m, N;
int main() {
n = readint(); m = readint(); N = readint();
int nx = 0, ny = 0;
while(N--) {
char op = readop();
if(op == 'U') ny++;
else if(op == 'D') ny--;
else if(op == 'L') nx--;
else if(op == 'R') nx++;
if(nx < 0 || nx >= n || ny < 0 || ny >= m) {
puts("invalid");
return 0;
}
}
puts("valid");
return 0;
}
Translation by KSkun
原题:問題「お金が引き出せない銀行」 | エンジニアが死滅シタ世界 〜アンドロイドとふたりぼっちで生きろ〜
你正在编写一个用于从银行存款中取钱的程序。
你知道你的存款n以及要取的钱数w。
取钱时,如果取钱后的余额为负值,则输出error,否则输出余额。
n
w
如果取钱后的余额为负值,则输出error,否则输出余额。
输入:
10000
1020
输出:
8980
输入:
1000
5000
输出:
error
// Code by KSkun, 2019/1
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
typedef long long LL;
inline char fgc() {
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
? EOF : *p1++;
}
inline LL readint() {
LL res = 0, neg = 1; char c = fgc();
for(; !isdigit(c); c = fgc()) if(c == '-') neg = -1;
for(; isdigit(c); c = fgc()) res = res * 10 + c - '0';
return res * neg;
}
inline char readsingle() {
char c;
while(!isgraph(c = fgc())) {}
return c;
}
int n, w;
int main() {
scanf("%d%d", &n, &w);
if(w > n) puts("error");
else printf("%d\n", n - w);
return 0;
}