Submission #1304736

#TimeUsernameProblemLanguageResultExecution timeMemory
1304736quollcucumber`Pinball (JOI14_pinball)C++20
11 / 100
18 ms27508 KiB
#include <bits/stdc++.h> #define int long long using namespace std; #define mod 9999991 int ar[mod]; int find(int a, int b) { return ((a * 9999973ll) % mod + b) % mod; } signed main(){ // int a = 1000000000ll * 9999973ll; // cout<<a<<'\n'; // cout<<find(1000000000, 7)<<'\n'; int m, n; cin>> m >> n; pair<pair<int, int>, pair<int, int>> arr[m]; for(int i = 0; i < m;i ++) { cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second.first >> arr[i].second.second; } // int best[m][m]; // fist is arr[i].first.first, second is arr[i].second.second vector<pair<int, int>> best; // for(int i = 0; i < m; i++) { // for(int j = 0; j < m; j++) { // best[i][j] = LONG_LONG_MAX; // } // } for(int i = m-1; i >= 0; i--) { if(ar[find(arr[i].first.first, arr[i].first.second)] == 0ll) { ar[find(arr[i].first.first,arr[i].first.second)] = arr[i].second.second; best.push_back({arr[i].first.first, arr[i].first.second}); }else { ar[find(arr[i].first.first, arr[i].first.second)] = min(ar[find(arr[i].first.first, arr[i].first.second)], arr[i].second.second); } for(pair<int, int> j : best) { if(arr[i].second.first >= j.first && arr[i].second.first <= j.second) { int left = min(j.first, arr[i].first.first); int right = max(j.second, arr[i].first.second); if(ar[find(left, right)] == 0) { ar[find(left, right)] = ar[find(j.first,j.second)] + arr[i].second.second; best.push_back({left, right}); }else { ar[find(left,right)] = min(ar[find(left,right)] , ar[find(j.first,j.second)] + arr[i].second.second); } } } } if(ar[find(1, n)] == 0) { cout<<-1<<'\n'; }else { cout<<ar[find(1,n)] <<'\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...