QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#135783#5260. The GameviniciuslettieriWA 1ms3532kbC++202.8kb2023-08-06 00:24:312023-08-06 00:24:32

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-06 00:24:32]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3532kb
  • [2023-08-06 00:24:31]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

deque<int> hand(8);
deque<int> draw(90);
vector<int> rows[4] = {{1}, {1}, {100}, {100}};

bool play_trick(vector<int> &row, auto card, bool asc) {
    int diff = abs(*card - *row.rbegin());
    if(diff == 10) {
        //cout << "won trick for " << *card << " with row val " << *row.rbegin() << " = " << diff << endl;
        row.push_back(*card);
        hand.erase(card);
        return true;
    }
    return false;
}

void diff_regular(int row, auto card, int &min_dist, auto &min_itr, int &min_row, bool asc) {
    int diff = (*card - *rows[row].rbegin()) * (asc? 1: -1);
    //cout << "trying " << *card << " diff " << diff << " min " << min_dist;
    if(diff > 0 && diff < min_dist) {
        min_dist = diff;
        min_itr = card;
        min_row = row;
        //cout << "*";
    }
    //cout << endl;
}

bool play(bool &won) {
    if(hand.size() == 0) {
        won = true;
        return true;
    }

    for(auto itr = hand.begin(); itr < hand.end(); itr++) {
        if(play_trick(rows[0], itr, true)) return true;
        if(play_trick(rows[1], itr, true)) return true;
        if(play_trick(rows[2], itr, false)) return true;
        if(play_trick(rows[3], itr, false)) return true;
    }

    int min_dist = 100; auto min_itr = hand.end(); int min_row;
    for(auto card = hand.begin(); card < hand.end(); card++) {
        diff_regular(0, card, min_dist, min_itr, min_row, true);
        diff_regular(1, card, min_dist, min_itr, min_row, true);
        diff_regular(2, card, min_dist, min_itr, min_row, false);
        diff_regular(3, card, min_dist, min_itr, min_row, false);
    }
    
    if(min_itr != hand.end()) {
        //cout << "won regular for " << *min_itr << " with " << min_dist << " in row " << min_row << endl;
        rows[min_row].push_back(*min_itr);
        hand.erase(min_itr);
        return true;
    }

    return false;
}

void add_card() {
    if(draw.size() > 0) {
        hand.push_back(draw[0]);
        draw.pop_front();
    }
}

void print_state() {
    for(auto row: rows) {
        for(auto v: row) cout << v << " ";
        cout << "\n";
    }

    for(auto v: hand) cout << v << " ";
    cout << "\n";
    
    for(int i=0; i<(int)draw.size(); i++) 
        cout << draw[i] << " ";
    cout << "\n";
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    
    for(auto &v: hand) cin >> v;
    for(auto &v: draw) cin >> v;

    int i = 0;

    bool lost = false, won = false;
    while(lost == false && won == false && i++ < 20) {
        if(play(won) == false) { lost = true; break; } else if(won) { break; }
        if(play(won) == false) { lost = true; break; } else if(won) { break; }
        add_card();
        add_card();
    }

    print_state();

    return 0;
}

詳細信息

Test #1:

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

input:

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

output:

1 2 3 4 5 6 7 8 9 10 20 21 22 23 24 25 26 27 28 38 39 40 
1 11 12 13 14 15 16 17 18 19 29 30 31 32 33 34 35 36 37 47 
100 
100 
41 42 43 44 45 46 48 49 
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

result:

wrong answer 1st lines differ - expected: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...9 90 91 92 93 94 95 96 97 98 99', found: '1 2 3 4 5 6 7 8 9 10 20 21 22 23 24 25 26 27 28 38 39 40 '