# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
699678 |
2023-02-17T17:40:35 Z |
urosk |
Park (JOI17_park) |
C++14 |
|
414 ms |
716 KB |
#include "park.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
using namespace std;
#define maxn 1405
static int pl[1400];
ll n;
bool ok[maxn],use[maxn],lif[maxn];
ll deg[maxn];
vector<ll> dpt[maxn];
bool ask(ll x,ll y){
for(ll i = 0;i<n;i++) pl[i] = use[i];
pl[x] = pl[y] = 1;
//ceri(pl,0,n-1);
return Ask(x,y,pl);
}
void add(ll x,ll y){
if(x>y) swap(x,y);
//cerr<<"uv: "<<x<< " "<<y<<endl;
Answer(x,y);
}
ll get(ll x){
ll l = 0,r = n-1,mid,rez;
while(l<=r){
mid = (l+r)/2;
for(ll i = 0;i<n;i++) use[i] = ok[i];
for(ll i = 0;i<=mid;i++) use[i] = 1;
if(!ask(0,x)){
rez = mid;
l = mid+1;
}else r = mid-1;
}
rez++;
//cerr<<"get: "<<x<< " "<<rez<<endl;
return rez;
}
void reshi(ll x){
//here;
//ceri(ok,0,n-1);
//dbg(x);
for(ll i = 0;i<n;i++) use[i] = ok[i];
while(!ask(0,x)){
reshi(get(x));
for(ll i = 0;i<n;i++) use[i] = ok[i];
}
for(ll d = n-1;d>=0;d--){
ll l = 0,r = sz(dpt[d])-1,mid,rez = -1;
while(l<=r){
mid = (l+r)/2;
for(ll i = 0;i<n;i++) use[i] = ok[i];
for(ll i = 0;i<=mid;i++) use[dpt[d][i]] = 0;
if(!ask(0,x)){
rez = mid;
r = mid-1;
}else l = mid+1;
}
if(rez!=-1){
add(x,dpt[d][rez]);
dpt[d+1].pb(x);
ok[x] = 1;
return;
}
}
ll rez = 0,d = 0;
add(x,dpt[d][rez]);
dpt[d+1].pb(x);
ok[x] = 1;
}
void Detect(int T,int N){
n = N;
ok[0] = 1;
dpt[0].pb(0);
lif[0] = 1;
for(ll i = 1;i<n;i++) if(!ok[i]) reshi(i);
return;
}
/*
1
6
7
0 1
0 3
1 2
1 4
2 4
2 5
3 4
1
6
5
0 1
1 2
1 4
2 5
3 4
*/
Compilation message
park.cpp: In function 'long long int get(long long int)':
park.cpp:53:8: warning: 'rez' may be used uninitialized in this function [-Wmaybe-uninitialized]
53 | rez++;
| ~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
233 ms |
480 KB |
Output is correct |
2 |
Correct |
19 ms |
536 KB |
Output is correct |
3 |
Correct |
67 ms |
716 KB |
Output is correct |
4 |
Correct |
221 ms |
624 KB |
Output is correct |
5 |
Correct |
225 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
363 ms |
576 KB |
Output is correct |
2 |
Correct |
414 ms |
464 KB |
Output is correct |
3 |
Correct |
406 ms |
576 KB |
Output is correct |
4 |
Correct |
317 ms |
560 KB |
Output is correct |
5 |
Incorrect |
410 ms |
572 KB |
Wrong Answer[5] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
258 ms |
540 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
182 ms |
580 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |