QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#428421#7281. How to Avoid Disqualification in 75 Easy StepsCrafticat#10.000001 4ms3976kbC++143.1kb2024-06-01 19:23:272024-06-01 19:23:28

Judging History

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

  • [2024-06-01 19:23:28]
  • 评测
  • 测评结果:10.000001
  • 用时:4ms
  • 内存:3976kb
  • [2024-06-01 19:23:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

std::vector<int> wait();
void send(std::vector<int>);

vector<int> toVec(set<int> &s) {
    vector<int> t(s.begin(),s.end());
    return t;
}

std::pair<int, int> scout(int R, int H) {
    int T = 70;
    int Z =1000 / 4;
    vector<vector<int>> q(T);
    for (int i = 0; i < T; ++i) {
        set<int> s;
        while (s.size() < Z) {
            s.insert(rand()% 1000 + 1);
        }
        q[i] = toVec(s);
        send(q[i]);
    }
    auto r = wait();

    set<int> pos;
    for (int i = 1; i <= 1000; ++i) {
        pos.insert(i);
    }
    for (int i = 0; i < T; ++i) {
        if (r[i] == false) {
            for (auto x : q[i]) {
                pos.erase(x);
            }
        }
    }
    auto res = toVec(pos);
    if (res.size() == 2) return {res[0],res[1]};
    if (res.size() == 1) return {res[0],res[0]};
    exit(5);
}

#if DEBUG
namespace sample_grader {

using std::cout;
using std::cin;
using std::endl;
using std::set;
using std::swap;
using std::vector;

constexpr int N = 1000;

int R, H;
int r, h;
int a, b;
vector<int> answers;

[[noreturn]] void invalid_input()
{
    cout << "Invalid input" << endl;
    exit(0);
}

[[noreturn]] void wrong_answer(const char *msg)
{
    cout << msg << endl;
    exit(0);
}

void print_vector(vector<int> v)
{
    cout << "{";
    for (size_t i = 0; i < v.size(); ++i) {
        cout <<  v[i];
        if (i + 1 != v.size()) cout << ", ";
    }
    cout << "}";
}

} // namespace sample_grader


void send(std::vector<int> positions)
{
    using namespace sample_grader;
    //cout << "send(";
    //print_vector(positions);
    //cout << ")" << endl;

    ++r;
    if (r > R) wrong_answer("Out of robots");

    set<int> position_set;
    int curr_answer = 0;
    for (int x : positions) {
        if (x < 1 or x > N or position_set.find(x) != position_set.end()) {
            wrong_answer("Invalid send");
        }
        position_set.insert(x);

        if (x == a or x == b) curr_answer = 1;
    }

    answers.push_back(curr_answer);
}

std::vector<int> wait()
{
    using namespace sample_grader;
    h++;
    //cout << "wait()";
    //if (h <= H) {
    //    cout << " returns ";
    //    print_vector(answers);
    //}
    cout << endl;

    if (h > H) wrong_answer("Out of time");

    vector<int> result = answers;
    answers.clear();
    return result;
}


int main()
{
    using namespace sample_grader;
    if (!(cin >> R >> H >> a >> b) || R <= 0 || H <= 0) invalid_input();
    for (int i = 0; i < 100; ++i) {
        if (a > b) swap(a, b);
        if (a < 1 or b > N) invalid_input();

        auto p = scout(R, H);
        cout << "scout(" << R << ", " << H << ") returned {" << p.first << ", " << p.second << "}" << endl;

        if (p.first > p.second) swap(p.first, p.second);

        if (p.first == a and p.second == b) {
            cout << "Correct: " << r << " robot(s) used, " << h << " hour(s) passed" << endl;
        } else {
            wrong_answer("Wrong answer");
        }
    }
    return 0;
}
#endif

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:



output:


result:

wrong answer Not correct

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

\x14

output:


result:

wrong answer Not correct

Subtask #3:

score: 0
Wrong Answer

Test #66:

score: 0
Wrong Answer
time: 2ms
memory: 3900kb

input:

\x1e

output:


result:

wrong answer Not correct

Subtask #4:

score: 10
Acceptable Answer

Test #120:

score: 10
Acceptable Answer
time: 4ms
memory: 3936kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #121:

score: 10
Acceptable Answer
time: 3ms
memory: 3972kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #122:

score: 10
Acceptable Answer
time: 3ms
memory: 3736kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #123:

score: 10
Acceptable Answer
time: 0ms
memory: 3640kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #124:

score: 10
Acceptable Answer
time: 3ms
memory: 3736kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #125:

score: 10
Acceptable Answer
time: 3ms
memory: 3624kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #126:

score: 10
Acceptable Answer
time: 3ms
memory: 3744kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #127:

score: 10
Acceptable Answer
time: 3ms
memory: 3976kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #128:

score: 10
Acceptable Answer
time: 3ms
memory: 3680kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #129:

score: 10
Acceptable Answer
time: 4ms
memory: 3748kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #130:

score: 10
Acceptable Answer
time: 4ms
memory: 3676kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #131:

score: 10
Acceptable Answer
time: 4ms
memory: 3744kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #132:

score: 10
Acceptable Answer
time: 3ms
memory: 3732kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #133:

score: 10
Acceptable Answer
time: 4ms
memory: 3748kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed

Test #134:

score: 10
Acceptable Answer
time: 0ms
memory: 3740kb

input:

K

output:


result:

points 0.13333334030 points  0.13333334030 Correct: 70 robot(s) used, 1 hour(s) passed