QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324086#5595. Hunt the Wumpusthanhha1210WA 1ms3824kbC++171.6kb2024-02-10 15:48:512024-02-10 15:48:51

Judging History

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

  • [2024-02-10 15:48:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-02-10 15:48:51]
  • 提交

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." ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

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: 3824kb

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: 1ms
memory: 3556kb

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!'