QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#324057 | #5595. Hunt the Wumpus | thanhha1210 | WA | 1ms | 3588kb | C++17 | 1.4kb | 2024-02-10 15:35:37 | 2024-02-10 15:35:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int nearest(int x, int y,vector<pair<int,int>> pos){
int d = 1e9;
for(int i = 0; i < pos.size(); i++){
if ((abs(x - pos[i].first) + abs(y - pos[i].second)) < d)
d = abs(x - pos[i].first) + abs(y - pos[i].second);
}
return d;
}
void find(int x, int y,vector<pair<int,int>>& pos) {
for (int i = 0; i < pos.size(); i++) {
if (pos[i].first == x && pos[i].second == y)
pos.erase(pos.begin() + i);
}
}
int main() {
int s;
string t;
int grid[10][10];
int x, y;
vector<pair<int,int>> pos;
cin >> s;
for(int i = 0; i < 4; i++){
s = s + floor(s/13) + 15;
int z = s % 100;
x = z / 10, y = z % 10;
pos.emplace_back(make_pair(x,y));
grid[x][y] = 1;
}
int user_score = 0;
while (pos.size()) {
cin >> t;
x = t[0] - '0';
y = t[1] - '0';
if(grid[x][y] == 1){
cout << "You hit a wumpus!" << endl;
find(x,y,pos);
grid[x][y] = 0;
if (pos.size() != 0)
cout << nearest(x,y,pos) << endl;
}
else {
cout << nearest(x,y,pos) << endl;
}
user_score ++;
}
cout << "Your score is " << user_score << " moves." ;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3524kb
input:
203811 00 01 02 03
output:
You hit a wumpus! 1 You hit a wumpus! 1 You hit a wumpus! 1 You hit a wumpus! Your score is 4 moves.
result:
ok 8 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3588kb
input:
101628 00 40 60 68 78 95
output:
6 2 You hit a wumpus! 8 1 You hit a wumpus! 5 You hit a wumpus! Your score is 6 moves.
result:
wrong answer 1st lines differ - expected: '4', found: '6'