QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#324057#5595. Hunt the Wumpusthanhha1210WA 1ms3588kbC++171.4kb2024-02-10 15:35:372024-02-10 15:35:38

Judging History

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

  • [2024-02-10 15:35:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-02-10 15:35:37]
  • 提交

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'