Submission #533545

#TimeUsernameProblemLanguageResultExecution timeMemory
533545cadmiumskyPinball (JOI14_pinball)C++14
11 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int n, m; const ll inf = 1e16 + 5; const int nmax = 3e5 + 2; #define left deobiceicineintreabasussy #define right deobiceicineintreababaka struct AINT { ll tree[4 * nmax]; ll query(int l, int r, int node = 1, int cl = 1, int cr = n) { //cout << l << ' ' << r << '\t' << cl << ' ' << cr << ' ' << tree[node] << '\n'; if(r < cl || cr < l) return inf; if(l <= cl && cr <= r) return tree[node]; int mid = cl + cr >> 1; return min(query(l, r, 2 * node, cl, mid), query(l, r, 2 * node + 1, mid + 1, cr)); } void upd(int poz, ll val, int node = 1, int cl = 1, int cr = n) { tree[node] = min(tree[node], val); if(cl == cr) return; int mid = cl + cr >> 1; if(poz <= mid) return upd(poz, val, 2 * node, cl, mid); return upd(poz, val, 2 * node + 1, mid + 1, cr); } // asta se numeste smenul lui nicu void construct(int node = 1, int cl = 1, int cr = n) { tree[node] = inf; if(cl == cr) return; int mid = cl + cr >> 1; construct(2 * node, cl, mid); construct(2 * node + 1, mid + 1, cr); } }; AINT left, right; #define norm deobiceicineintreaba map<int,int> norm; int main() { cin >> m >> n; vector<tuple<int,int,int,int> > v(m); for(auto &[a, b, c, d] : v) { cin >> a >> b >> c >> d; norm[a]; norm[b]; norm[c]; } norm[1]; norm[n]; int cnt = 1; for(auto &x : norm) x.second = cnt++; n = cnt - 1; left.construct(); right.construct(); left.upd(1, 0); right.upd(n, 0); ll minn = inf; for(auto [a, b, c, d] : v) { a = norm[a]; b = norm[b]; c = norm[c]; ll l = left.query(a, c), r = right.query(c, b); //cout << l << ' ' << r << '\n'; minn = min(minn, l + r + d); left.upd(c, l + d); right.upd(c, r + d); } if(minn >= 1e16 + 1) cout << -1 << '\n'; else cout << minn << '\n'; }

Compilation message (stderr)

pinball.cpp: In member function 'long long int AINT::query(int, int, int, int, int)':
pinball.cpp:18:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |     int mid = cl + cr >> 1;
      |               ~~~^~~~
pinball.cpp: In member function 'void AINT::upd(int, long long int, int, int, int)':
pinball.cpp:25:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |     int mid = cl + cr >> 1;
      |               ~~~^~~~
pinball.cpp: In member function 'void AINT::construct(int, int, int)':
pinball.cpp:34:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |     int mid = cl + cr >> 1;
      |               ~~~^~~~
pinball.cpp: In function 'int main()':
pinball.cpp:47:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |   for(auto &[a, b, c, d] : v) {
      |             ^
pinball.cpp:64:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |   for(auto [a, b, c, d] : v) {
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...