# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
428538 |
2021-06-15T12:41:52 Z |
errorgorn |
Park (JOI17_park) |
C++17 |
|
1010 ms |
772 KB |
#include "park.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int t,n;
int Ask(int i,int j,vector<int> v){
//cout<<"Ask: "<<i<<" "<<j<<" | "; for (auto &it:v) cout<<it<<" "; cout<<endl;
if (i>j) swap(i,j); //the fuck?
int arr[n];
memset(arr,0,sizeof(arr));
for (auto &it:v) arr[it]=1;
return Ask(i,j,arr);
}
void ans(int i,int j){
if (i>j) swap(i,j);
Answer(i,j);
}
void rec(vector<int> v,int p){
//cout<<"debug: "; for (auto &it:v) cout<<it<<" "; cout<<endl;
if (sz(v)==1) return;
shuffle(all(v),rng);
if (t==3) rep(x,0,sz(v)) if (v[x]==p) swap(v[x],v.back());
int pivot=v.back(); v.pob();
while (sz(v)){
vector<int> split;
vector<int> rest;
split.pub(v.back());
for (auto &it:v){
if (it==split[0]) continue;
if (Ask(split[0],it,v)==1) split.pub(it);
else rest.pub(it);
}
//now we need to find how split is connected to pivot
vector<int> cset={pivot};
int connect;
for (auto &it:split){
cset.pub(it);
if (Ask(it,pivot,cset)){
ans(it,pivot);
connect=it;
break;
}
}
rec(split,connect);
v=rest;
}
}
void Detect(int T, int N) {
t=T,n=N;
if (t==1){
rep(x,0,n) rep(y,x+1,n){
if (Ask(x,y,{x,y})==1) Answer(x,y);
}
}
else{
vector<int> proc;
rep(x,0,n) proc.pub(x);
rec(proc,0);
}
}
Compilation message
park.cpp: In function 'void rec(std::vector<int>, int)':
park.cpp:79:6: warning: 'connect' may be used uninitialized in this function [-Wmaybe-uninitialized]
79 | rec(split,connect);
| ~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
7 ms |
332 KB |
Output is correct |
3 |
Correct |
8 ms |
332 KB |
Output is correct |
4 |
Correct |
8 ms |
204 KB |
Output is correct |
5 |
Correct |
8 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
524 KB |
Output is correct |
2 |
Correct |
117 ms |
500 KB |
Output is correct |
3 |
Correct |
95 ms |
612 KB |
Output is correct |
4 |
Correct |
152 ms |
456 KB |
Output is correct |
5 |
Correct |
112 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
444 KB |
Output is correct |
2 |
Correct |
104 ms |
436 KB |
Output is correct |
3 |
Correct |
81 ms |
552 KB |
Output is correct |
4 |
Correct |
87 ms |
440 KB |
Output is correct |
5 |
Correct |
62 ms |
460 KB |
Output is correct |
6 |
Correct |
62 ms |
432 KB |
Output is correct |
7 |
Correct |
89 ms |
460 KB |
Output is correct |
8 |
Correct |
79 ms |
436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
381 ms |
744 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1010 ms |
772 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |