# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
428582 |
2021-06-15T13:00:16 Z |
lyc |
Park (JOI17_park) |
C++14 |
|
166 ms |
536 KB |
#include "park.h"
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
static int Place[1400];
void myans(int i, int j) {
if (i > j) swap(i,j);
Answer(i,j);
}
bool myask(int i, int j, vector<int> v) {
if (i > j) swap(i,j);
v.push_back(i);
v.push_back(j);
for (int& x : v) Place[x] = 1;
int ret = Ask(i,j,Place);
for (int& x : v) Place[x] = 0;
return ret;
}
vector<int> ans;
void solve(vector<int> v) {
int l = 0;
while (true) {
int it = SZ(ans);
FOR(i,0,SZ(ans)-1) if (ans[i] == l) { it = i+1; break; }
if (it >= SZ(ans)) break;
int u = ans[it];
while (true) {
//TRACE("CHECK" _ l _ u);
if (myask(l,u,{})) {
//TRACE("ANSWER" _ l _ u);
myans(l,u);
l = u;
break;
}
int lo = -1, hi = SZ(v);
while (hi-lo > 1) {
int mid = (lo+hi)/2;
vector<int> v2;
FOR(i,0,mid) v2.push_back(v[i]);
if (myask(l,u,v2)) hi = mid;
else lo = mid;
}
u = v[hi];
v.erase(find(ALL(v),u));
FOR(i,0,SZ(ans)-1) if (ans[i] == l) {
ans.insert(ans.begin()+i+1, u);
break;
}
}
}
//for (int& x : v) { cout << x << ' '; } cout << endl;
//for (int& x : ans) { cout << x << ' '; } cout << endl;
}
void Detect(int T, int N) {
if (T == 1) {
FOR(i,0,N-1){
FOR(j,i+1,N-1){
Place[i] = Place[j] = 1;
if (Ask(i,j,Place)) Answer(i,j);
Place[i] = Place[j] = 0;
}
}
} else if (T == 2) {
ans.push_back(0);
ans.push_back(N-1);
vector<int> v;
FOR(i,1,N-2) v.push_back(i);
solve(v);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
5 ms |
296 KB |
Output is correct |
3 |
Correct |
6 ms |
292 KB |
Output is correct |
4 |
Correct |
7 ms |
324 KB |
Output is correct |
5 |
Correct |
6 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
536 KB |
Output is correct |
2 |
Correct |
166 ms |
492 KB |
Output is correct |
3 |
Correct |
127 ms |
492 KB |
Output is correct |
4 |
Correct |
69 ms |
516 KB |
Output is correct |
5 |
Correct |
74 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
304 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |