QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325183#5581. Champernowne CountWonchanKimTL 0ms0kbC++141.6kb2024-02-11 05:30:442024-02-11 05:30:44

Judging History

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

  • [2024-02-11 05:30:44]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-02-11 05:30:44]
  • 提交

answer

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

int nearest(int x, int y,vector<pair<int,int>> pos){
    int d = 1000;
    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 hit(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 find(int x, int y,const 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 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 (!find(x,y, pos)) {
            pos.emplace_back(make_pair(x,y)); 
        }
    }
    int user_score = 0;
    while (pos.size() > 0) {
        cin >> t;
        x = t[0] - '0';
        y = t[1] - '0';
            
        if(find(x, y, pos)){
            hit(x, y, pos);
            cout << "You hit a wumpus!" << endl;
            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." ;
    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

4 2

output:

53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
...

result: