제출 #981595

#제출 시각아이디문제언어결과실행 시간메모리
981595IUA_Hasin밀림 점프 (APIO21_jumps)C++17
0 / 100
4077 ms571080 KiB
#include "jumps.h" #include <bits/stdc++.h> #define ll long long using namespace std; const ll M = 2e5+10; vector<ll> graph[M]; set<pair<ll, ll>> indlevel; map<pair<ll, ll>, ll> valevel; //vector<set<ll>> inconnected[M]; vector<ll> outconnected[M]; //ll curr_level[M]; //ll vis[M][M]; map<pair<ll, ll>, ll> vis; vector<ll> H2; void init(int N, std::vector<int> H) { vector<ll> v[N+1]; for(int i=0; i<N; i++){ ll a = H[i]; v[a].push_back(i); H2.push_back(a); } set<ll> s; for(int i=0; i<N; i++){ s.insert(i); } for(int i=1; i<=N; i++){ if(i==N){ break; } ll ind = v[i][0]; ll val = H[ind]; //cout<<ind<<" "<<val<<endl; auto it1 = s.lower_bound(ind); auto it2 = s.upper_bound(ind); it1--; ll temp1, temp2; if(it1!=s.end()){ temp1 = *it1; temp1 = H[temp1]; //cout << temp1 << " " << val << " " << 65 << endl; vis[{val, temp1}] = 1; outconnected[temp1].push_back(val); indlevel.insert({val, temp1}); valevel[{val, temp1}] = 1; for(auto u : outconnected[val]){ if(vis[{u, temp1}]==0){ indlevel.insert({u, temp1}); valevel[{u, temp1}] = valevel[{u, val}]+1; vis[{u, temp1}] = 1; //cout << temp1 << " " << u << " " << 76 << endl; outconnected[temp1].push_back(u); } } } if(it2!=s.end()){ temp1 = *it2; temp1 = H[temp1]; //cout << temp1 << " " << val << " " << 84 << endl; vis[{val, temp1}] = 1; outconnected[temp1].push_back(val); indlevel.insert({val, temp1}); valevel[{val, temp1}] = 1; for(auto u : outconnected[val]){ if(vis[{u, temp1}]==0){ indlevel.insert({u, temp1}); valevel[{u, temp1}] = valevel[{u, val}]+1; vis[{u, temp1}] = 1; //cout << temp1 << " " << u << " " << 97 << endl; outconnected[temp1].push_back(u); } } } // cout<<endl; // cout<<endl; auto itt = s.find(ind); s.erase(itt); } // cout<<endl; // cout<<endl; // cout<<endl; // for(int i=1; i<=N; i++){ // cout << i << endl; // for(int j=0; j<outconnected[i].size(); j++){ // cout << outconnected[i][j] << " "; // } // cout<<endl; // cout<<endl; // } } int minimum_jumps(int A, int B, int C, int D) { ll start = H2[A]; ll end = H2[C]; //cout << start << " " << end << endl; ll ans = vis[{start, end}]; if(ans==0){ return -1; } else { ll ans2 = valevel[{start, end}]; return ans2; } }

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

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:46:19: warning: unused variable 'temp2' [-Wunused-variable]
   46 |         ll temp1, temp2;
      |                   ^~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...