QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324052#5595. Hunt the Wumpusleleco3248#WA 1ms3608kbC++171.4kb2024-02-10 15:33:192024-02-10 15:33:19

Judging History

你现在查看的是最新测评结果

  • [2024-02-10 15:33:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-02-10 15:33:19]
  • 提交

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'