Submission #1304747

#TimeUsernameProblemLanguageResultExecution timeMemory
1304747quollcucumber`Pinball (JOI14_pinball)C++20
29 / 100
1115 ms402244 KiB
// #pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> // #pragma target("avx2") #define int long long using namespace std; #define mod 59999989ll int ar[mod + 1000]; #define find(a, b) (((a * 9999973ll) + 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); } int sz= best.size(); for(int k = 0; k < sz; k++) { pair<int, int> j = best[k]; 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...