제출 #699682

#제출 시각아이디문제언어결과실행 시간메모리
699682uroskPark (JOI17_park)C++14
67 / 100
405 ms588 KiB
#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],dpt[maxn];
bool ask(ll x,ll y){
    if(x>y) swap(x,y);
    for(ll i = 0;i<n;i++) pl[i] = use[i];
    pl[x] = pl[y] = 1;
    //cerr<<"ask: "<<x<< " "<<y<<endl;
    //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;
}
bool cmp(ll x,ll y){
    return dpt[x]<dpt[y];
}
vector<ll> v;
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];
    }
    ll l = 0,r = sz(v)-1,mid,rez;
    //cer(v);
    while(l<=r){
        mid = (l+r)/2;
        for(ll i = 0;i<=n;i++) use[i] = 0;
        for(ll i = 0;i<=mid;i++) use[v[i]] = 1;
        if(ask(x,0)){
            rez = mid;
            r = mid-1;
        }else l = mid+1;
    }
    rez = v[rez];
    ok[x] = 1;
    dpt[x] = dpt[rez]+1;
    add(x,rez);
    v.pb(x);
    sort(all(v),cmp);
}
void Detect(int T,int N){
    n = N;
    ok[0] = 1;
    v.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
*/

컴파일 시 표준 에러 (stderr) 메시지

park.cpp: In function 'long long int get(long long int)':
park.cpp:54:8: warning: 'rez' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |     rez++;
      |     ~~~^~
park.cpp: In function 'void reshi(long long int)':
park.cpp:82:16: warning: 'rez' may be used uninitialized in this function [-Wmaybe-uninitialized]
   82 |     rez = v[rez];
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...