QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323305#5595. Hunt the WumpusqyockeyWA 1ms3652kbC++142.1kb2024-02-09 08:06:162024-02-09 08:06:16

Judging History

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

  • [2024-02-09 08:06:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3652kb
  • [2024-02-09 08:06:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b)   for (int i = a; i < (b); ++i)
#define lrep(i, a, b)  for (long i = a; i < (b); ++i)
#define all(x)         (x).begin(), (x).end()
#define sz(x)          (int)(x).size()
#define ia(n)          std::array<int, n>
#define lla(n)         std::array<ll, n>

using vi =             std::vector<int>;
using pii =            std::pair<int, int>;
using ll =             long long;
using vll =            std::vector<ll>;
using pll =            std::pair<ll, ll>;

int dist(pii a, pii b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
    long seed;
    cin >> seed;
    array<pii, 4> wumpuses;
    rep (i, 0, 4) {
        seed = seed + seed/13 + 15;
        wumpuses[i] = {(seed % 100) / 10, seed % 10};
        rep (j, 0, i) {
            if (wumpuses[i] == wumpuses[j]) {
                --i;
                break;
            }
        }
    }
    int moves = 0;
    int remaining = 0xf;
    while (remaining) {
        pii guess;
        cin.ignore();
        guess.first = cin.get() - '0';
        guess.second = cin.get() - '0';
        int dist = __INT_MAX__;
        rep (i, 0, 4) {
            int d = abs(wumpuses[i].first - guess.first)
                  + abs(wumpuses[i].second - guess.second);
            if (d < dist && remaining & (1 << i)) {
                dist = d;
            }
            if (dist == 0) {
                cout << "You hit a wumpus!" << '\n';
                remaining &= ~(1 << i);
                break;
            }
        }
        if (dist != 0) {
            cout << dist << '\n';
        } else if (remaining) {
            dist = __INT_MAX__;
            rep (i, 0, 4) {
                int d = abs(wumpuses[i].first - guess.first)
                    + abs(wumpuses[i].second - guess.second);
                if (d < dist && remaining & (1 << i)) {
                    dist = d;
                }
            }
            cout << dist << '\n';
        }
        ++moves;
    }
    cout << "Your score is " << moves << " moves\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3652kb

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:

wrong answer 8th lines differ - expected: 'Your score is 4 moves.', found: 'Your score is 4 moves'