Submission #1008504

# Submission time Handle Problem Language Result Execution time Memory
1008504 2024-06-26T13:53:08 Z AdamGS Treatment Project (JOI20_treatment) C++17
0 / 100
39 ms 11604 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
const int LIM=1e5+7;
pair<pair<ll,ll>,pair<ll,ll>>T[LIM];
ll odl[LIM];
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  priority_queue<pair<ll,ll>>q;
  rep(i, m) {
    cin >> T[i].nd.st >> T[i].st.st >> T[i].st.nd >> T[i].nd.nd;
    odl[i]=INF;
    if(T[i].st.st==1) q.push({-T[i].nd.nd, i});
  }
  while(!q.empty()) {
    ll o=-q.top().st, p=q.top().nd; q.pop();
    if(odl[p]<=o) continue;
    odl[p]=o;
    rep(i, n) {
      if(T[p].st.nd-T[i].st.st+1>=abs(T[p].nd.st-T[i].nd.st)) q.push({-o-T[i].nd.nd, i});
    }
  }
  ll ans=INF;
  rep(i, n) if(T[i].st.nd==n) ans=min(ans, odl[i]);
  if(ans==INF) ans=-1;
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 11604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 7 ms 3856 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 7 ms 3856 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 11604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -