QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#325189 | #5595. Hunt the Wumpus | WonchanKim | WA | 0ms | 3576kb | C++14 | 1.6kb | 2024-02-11 05:31:58 | 2024-02-11 05:31:58 |
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);
}
}
bool find1(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)
return true;
}
return false;
}
int main() {
int s;
string t;
int grid[10][10];
int x, y;
vector<pair<int,int>> pos;
cin >> s;
while (pos.size() < 4) {
s = s + floor(s/13) + 15;
int z = s % 100;
x = z / 10, y = z % 10;
if (!find1(x,y, pos)) {
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: 0ms
memory: 3576kb
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: 0
Accepted
time: 0ms
memory: 3520kb
input:
101628 00 40 60 68 78 95
output:
4 You hit a wumpus! 2 You hit a wumpus! 8 1 You hit a wumpus! 5 You hit a wumpus! Your score is 6 moves.
result:
ok 10 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3516kb
input:
366476 26 31 76 94 77 79 23 19 56 16 88 96 11 84 63 84 75 48 68 93 59 88 70 37 50 88 41 70 72 13 23 96 23 09 74 87 45 15 61 59 05 86 35 87 10 33 23 34 35 01 39 85 67 88 14 34 01 52 39 33 04 03 94 63 76 98 53 20 27 56 88 22 71 26 06 14 98 01 91 90 71 03 57 97 42 24 40 40 44 48 99 81
output:
3 5 2 You hit a wumpus! 4 1 3 6 7 You hit a wumpus! 2 6 3 4 7 3 4 3 3 3 1 3 3 3 2 3 4 3 4 2 2 9 8 4 8 8 4 2 4 7 2 3 8 3 5 2 8 7 8 6 5 8 5 4 You hit a wumpus! 8 7 10 8 8 4 13 7 11 10 4 4 6 8 5 You hit a wumpus! 7 12 8 7 7 1 11 13 10 8 8 1 2 1 10 9 7 5 9 5 5 7 11 9 You hit a wumpus! Your score is 92 m...
result:
wrong answer 71st lines differ - expected: '7', found: 'You hit a wumpus!'