# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
296417 |
2020-09-10T14:28:46 Z |
BThero |
Park (JOI17_park) |
C++17 |
|
665 ms |
1016 KB |
// chrono::system_clock::now().time_since_epoch().count()
#include "park.h"
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static int tmp_arr[2005];
static int n;
bool ask(int a, int b, vector<int> &vec) {
if (a > b) {
swap(a, b);
}
fill(tmp_arr, tmp_arr + n, 0);
for (int x : vec) {
tmp_arr[x] = 1;
}
return Ask(a, b, tmp_arr);
}
void report(int a, int b) {
if (a > b) {
swap(a, b);
}
Answer(a, b);
}
namespace subtask1 {
void solve() {
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
vector<int> S;
S.pb(i);
S.pb(j);
if (ask(i, j, S)) {
report(i, j);
}
}
}
}
};
namespace subtask2 {
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
vector<int> calc(int L, int R, vector<int> S) {
vector<int> ret;
if (S.size() == 2) {
ret.pb(L);
ret.pb(R);
return ret;
}
int m = rnd() % S.size();
while (S[m] == L || S[m] == R) {
m = rnd() % S.size();
}
int M = S[m];
vector<int> A, B;
A.pb(L);
A.pb(M);
B.pb(M);
B.pb(R);
for (int x : S) {
if (x != L && x != M && x != R) {
vector<int> S2 = S;
S2.erase(find(all(S2), x));
if (ask(L, M, S2)) {
B.pb(x);
}
else {
A.pb(x);
}
}
}
A = calc(L, M, A);
B = calc(M, R, B);
for (int x : A) {
ret.pb(x);
}
ret.pop_back();
for (int x : B) {
ret.pb(x);
}
return ret;
}
void solve() {
vector<int> S;
for (int i = 0; i < n; ++i) {
S.pb(i);
}
S = calc(0, n - 1, S);
for (int i = 0; i + 1 < n; ++i) {
report(S[i], S[i + 1]);
}
}
};
namespace subtask3 {
void go(int v, vector<int> sub) {
if ((int)sub.size() == 1) {
return;
}
vector<int> S = sub;
S.erase(find(all(S), v));
vector<vector<int>> comp;
for (int x : sub) {
if (x != v) {
int p = 0;
while (p < (int)comp.size() && !ask(comp[p][0], x, S)) {
++p;
}
if (p == (int)comp.size()) {
comp.pb(vector<int>(1, x));
}
else {
comp[p].pb(x);
}
}
}
for (vector<int> nsub : comp) {
int root = -1;
for (int x : nsub) {
S.clear();
S.pb(v);
S.pb(x);
if (ask(v, x, S)) {
root = x;
}
}
assert(root != -1);
report(v, root);
go(root, nsub);
}
}
void solve() {
vector<int> S;
for (int i = 0; i < n; ++i) {
S.pb(i);
}
go(0, S);
}
};
void Detect(int T, int N) {
n = N;
if (T == 1) {
subtask1::solve();
}
else if (T == 2) {
subtask2::solve();
}
else {
subtask3::solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
512 KB |
Output is correct |
3 |
Correct |
12 ms |
384 KB |
Output is correct |
4 |
Correct |
13 ms |
384 KB |
Output is correct |
5 |
Correct |
13 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
512 KB |
Output is correct |
2 |
Correct |
70 ms |
512 KB |
Output is correct |
3 |
Correct |
61 ms |
640 KB |
Output is correct |
4 |
Correct |
108 ms |
512 KB |
Output is correct |
5 |
Correct |
87 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
504 KB |
Output is correct |
2 |
Correct |
95 ms |
512 KB |
Output is correct |
3 |
Correct |
83 ms |
512 KB |
Output is correct |
4 |
Correct |
101 ms |
512 KB |
Output is correct |
5 |
Correct |
87 ms |
512 KB |
Output is correct |
6 |
Correct |
84 ms |
504 KB |
Output is correct |
7 |
Correct |
91 ms |
512 KB |
Output is correct |
8 |
Correct |
81 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
141 ms |
636 KB |
Output is correct |
2 |
Incorrect |
612 ms |
888 KB |
Wrong Answer[5] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
665 ms |
1016 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |