QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#428517 | #7281. How to Avoid Disqualification in 75 Easy Steps | Crafticat# | 10.000001 | 4ms | 3996kb | C++14 | 3.8kb | 2024-06-01 19:59:21 | 2024-06-01 19:59:22 |
Judging History
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) {
set<int> pos;
for (int i = 1; i <= 1000; ++i) {
pos.insert(i);
}
for (int t = 0; t < H; ++t) {
auto posVec = toVec(pos);
int T = R / H;
int Z0 = max((int)posVec.size() / 4, 1);
int Z1 = max((int)posVec.size() / 4, 1);
vector<vector<int>> q(T);
for (int i = 0; i < T; ++i) {
set<int> s;
int Z = i < T / 2 ? Z0 : Z1;
while (s.size() < Z) {
s.insert(posVec[rand()%posVec.size()]);
}
q[i] = toVec(s);
send(q[i]);
}
auto r = wait();
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;
struct Sample {
Sample()= default;
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 << "}";
}
};
}
sample_grader::Sample s;
void send(std::vector<int> positions) {
using namespace sample_grader;
//cout << "send(";
//print_vector(positions);
//cout << ")" << endl;
++s.r;
if (s.r > s.R) s.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()) {
s.wrong_answer("Invalid send");
}
position_set.insert(x);
if (x == s.a or x == s.b) curr_answer = 1;
}
s.answers.push_back(curr_answer);
}
std::vector<int> wait()
{
using namespace sample_grader;
s.h++;
//cout << "wait()";
//if (h <= H) {
// cout << " returns ";
// print_vector(answers);
//}
cout << endl;
if (s.h > s.H) s.wrong_answer("Out of time");
vector<int> result = s.answers;
s.answers.clear();
return result;
}
int main()
{
srand(0);
int t = 0;
int corr = 0;
while (t < 1000) {
using namespace sample_grader;
s = Sample();
t++;
s.R = 30, s.H = 2;
s.a =rand() % 1000 + 1, s.b = rand()%1000 + 1;
if (s.a > s.b) swap(s.a, s.b);
auto p = scout(s.R, s.H);
//cout << "scout(" << s.R << ", " << s.H << ") returned {" << p.first << ", " << p.second << "}" << endl;
if (p.first > p.second) swap(p.first, p.second);
if (p.first == s.a and p.second == s.b) {
//cout << "Correct: " << s.r << " robot(s) used, " << s.h << " hour(s) passed" << endl;
corr++;
} else {
//cout << "Wrong ans";
}
}
cout << corr;
return 0;
}
#endif
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
input:
\x14
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #66:
score: 0
Runtime Error
input:
\x1e
output:
result:
Subtask #4:
score: 10
Acceptable Answer
Test #120:
score: 10
Acceptable Answer
time: 4ms
memory: 3760kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #121:
score: 10
Acceptable Answer
time: 4ms
memory: 3964kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #122:
score: 10
Acceptable Answer
time: 2ms
memory: 3712kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #123:
score: 10
Acceptable Answer
time: 2ms
memory: 3704kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #124:
score: 10
Acceptable Answer
time: 4ms
memory: 3764kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #125:
score: 10
Acceptable Answer
time: 4ms
memory: 3696kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #126:
score: 10
Acceptable Answer
time: 4ms
memory: 3708kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #127:
score: 10
Acceptable Answer
time: 2ms
memory: 3696kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #128:
score: 10
Acceptable Answer
time: 4ms
memory: 3700kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #129:
score: 10
Acceptable Answer
time: 1ms
memory: 3772kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #130:
score: 10
Acceptable Answer
time: 0ms
memory: 3736kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #131:
score: 10
Acceptable Answer
time: 0ms
memory: 3752kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #132:
score: 10
Acceptable Answer
time: 4ms
memory: 3996kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #133:
score: 10
Acceptable Answer
time: 4ms
memory: 3768kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed
Test #134:
score: 10
Acceptable Answer
time: 4ms
memory: 3760kb
input:
K
output:
result:
points 0.13333334030 points 0.13333334030 Correct: 75 robot(s) used, 1 hour(s) passed