QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#324052 | #5595. Hunt the Wumpus | leleco3248# | WA | 1ms | 3608kb | C++17 | 1.4kb | 2024-02-10 15:33:19 | 2024-02-10 15:33:19 |
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." ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
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: 3592kb
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'