QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90489#5260. The GameSolitaryDream#Compile Error//Java82.5kb2023-03-23 13:05:002023-03-23 13:05:05

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-03-23 13:05:05]
  • Judged
  • [2023-03-23 13:05:00]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
vector<int> rm;
vector<int> cur;
vector<int> st[4];
inline bool Check() {
    for (auto x : cur) {
        for (int d = 0; d < 2; ++d) {
            if (x > st[d].back() || x == st[d].back() - 10) return 1;
        }
        for (int d = 2; d < 4; ++d) {
            if (x < st[d].back() || x == st[d].back() + 10) return 1;
        }
    }
    return 0;
}
int main() {
    for (int i = 1, x; i <= 98; ++i) {
        scanf("%d", &x);
        rm.push_back(x);
    }
    reverse(rm.begin(), rm.end());
    for (int i = 0; i < 8; ++i) {
        cur.push_back(rm.back());
        rm.pop_back();
    }
    st[0].push_back(1);
    st[1].push_back(1);
    st[2].push_back(100);
    st[3].push_back(100);
    while (Check()) {
        for (int i = 0; i < 2; ++i) if (rm.size()) {
            cur.push_back(rm.back());
            rm.pop_back();
        }
        for (int round = 0; Check() && round < 2; ++round) {
            int cho = -1, cho2 = -1;
            for (int i = 0; i < (int)cur.size(); ++i) {
                if (cur[i] == st[0].back() - 10) cho = i, cho2 = 0;
                if (cur[i] == st[1].back() - 10) cho = i, cho2 = 1;
                if (cur[i] == st[2].back() + 10) cho = i, cho2 = 2;
                if (cur[i] == st[3].back() + 10) cho = i, cho2 = 3;
            }
            if (cho != -1) {
                st[cho2].push_back(cur[cho]);
                cur.erase(cur.begin() + cho);
                continue;
            }
            int delta = 1e9; cho = -1; cho2 = -1;
            auto Update = [&](int i, int d) {
                if (delta > abs(cur[i] - st[d].back())) {
                    delta = abs(cur[i] - st[d].back());
                    cho = i;
                    cho2 = d;
                }
            };
            for (int i = 0; i < (int)cur.size(); ++i) {
                if (cur[i] > st[0].back()) Update(i, 0);
                if (cur[i] > st[1].back()) Update(i, 1);
                if (cur[i] < st[2].back()) Update(i, 2);
                if (cur[i] < st[3].back()) Update(i, 3);
            }
            st[cho2].push_back(cur[cho]);
            cur.erase(cur.begin() + cho);
        }
    }
    for (int d = 0; d < 4; ++d) {
        for (int i = 0; i < (int)st[d].size(); ++i) printf("%d ", st[d][i]);
        puts("");
    }
    for (int i = 0; i < (int)cur.size(); ++i) printf("%d ", cur[i]);
    puts("");
    reverse(rm.begin(), rm.end());
    for (auto x : rm) printf("%d ", x);
    puts("");
    return 0;
}

详细

Can't find the main class.