Submission #815714

#TimeUsernameProblemLanguageResultExecution timeMemory
815714OzyNew Home (APIO18_new_home)C++17
0 / 100
153 ms30216 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define pll pair<lli,lli> #define MAX_k 400 #define MAX 60000 #define INF (1ll<<60) #define LIM 10000000000 //para el vector de orden #define pos first #define tipo second.first #define id second.second lli n,q,k,a,b,c,d; vector<pair<lli,pll>> orden; multiset<lli> activos[MAX_k+2]; lli res[MAX]; void solve() { //inicializa lli last[MAX+2]; set<pll> activos; rep(i,1,n) { last[i] = -INF; activos.insert({-INF, i}); } for (auto act : orden) { if(act.tipo == 0) { activos.erase({last[act.id],act.id}); last[act.id] = act.pos; activos.insert({last[act.id],act.id}); } else { lli op = (*activos.begin()).first; lli mejor = abs( abs(op) - abs(act.pos) ); res[act.id] = min(res[act.id],mejor); } } } //solucion de s3 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k >> q; rep(i,1,n) { cin >> a >> b >> c >> d; orden.push_back({a,{0,b}}); } rep(i,1,q) { cin >> a >> b; orden.push_back({a,{1,i}}); } rep(i,1,q) res[i] = INF; sort(orden.begin(),orden.end()); solve(); reverse(orden.begin(), orden.end()); for(auto &act : orden) act.pos *= (-1); solve(); rep(i,1,q) if (res[i] > LIM) cout << "-1\n"; else cout << res[i] << "\n"; return 0; }
#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...