Submission #569478

#TimeUsernameProblemLanguageResultExecution timeMemory
569478mat_vPinball (JOI14_pinball)C++14
0 / 100
0 ms340 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begin(), (a).end() #define pb push_back #define ll long long #define pii pair<int,int> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less) mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int n,duz; int br = 0; map<int,int> poj; ll INF=1e5; struct prep{ int l,r,x; ll w; }niz[100005]; ll dp[100005]; ll sejv[100005]; ll seg[4*300005]; void update(int node, int l, int r, int poz, ll val){ if(l == r){ seg[node] = val; return; } int mid = (l + r) / 2; if(poz <= mid)update(node*2,l,mid,poz,val); else update(node*2+1,mid+1,r,poz,val); seg[node] = min(seg[node * 2 + 1], seg[node * 2]); } ll kveri(int node, int l, int r, int levo, int desno){ if(levo > r || l > desno)return INF; if(l >= levo && r <= desno)return seg[node]; int mid = (l + r) / 2; return min(kveri(node*2,l,mid,levo,desno), kveri(node*2+1,mid+1,r,levo,desno)); } void radi(){ update(1,1,duz,1,0); ff(i,2,duz)update(1,1,duz,i,INF); ff(i,1,n){ dp[i] = kveri(1,1,duz,niz[i].l,niz[i].r) + niz[i].w; update(1,1,duz,niz[i].x,kveri(1,1,duz,niz[i].l,niz[i].r)+niz[i].w); } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); INF *= INF; cin >> n >> duz; vector<int> svi; ff(i,1,n){ cin >> niz[i].l >> niz[i].r >> niz[i].x >> niz[i].w; svi.pb(niz[i].l); svi.pb(niz[i].r); svi.pb(niz[i].x); } svi.pb(duz); svi.pb(1); sort(svi.begin(),svi.end()); int lst = 0; int br = 0; for(auto c:svi){ if(c == lst)continue; br++; poj[c] = br; lst = c; } duz = poj[duz]; ff(i,1,n)niz[i] = {poj[niz[i].l], poj[niz[i].r], poj[niz[i].x], niz[i].w}; radi(); ff(i,1,n)sejv[i] = dp[i]; ff(i,1,n){ niz[i].l = duz-niz[i].l+1; niz[i].r = duz-niz[i].r+1; niz[i].x = duz-niz[i].x+1; swap(niz[i].r,niz[i].l); } radi(); ll ans = INF; ff(i,1,n){ ans = min(ans, dp[i] + sejv[i] - niz[i].w); } if(ans < INF/2)cout << ans << "\n"; else cout << -1 << "\n"; return 0; }

Compilation message (stderr)

pinball.cpp: In function 'void radi()':
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:58:5: note: in expansion of macro 'ff'
   58 |     ff(i,2,duz)update(1,1,duz,i,INF);
      |     ^~
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:59:5: note: in expansion of macro 'ff'
   59 |     ff(i,1,n){
      |     ^~
pinball.cpp: In function 'int main()':
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:73:5: note: in expansion of macro 'ff'
   73 |     ff(i,1,n){
      |     ^~
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:91:5: note: in expansion of macro 'ff'
   91 |     ff(i,1,n)niz[i] = {poj[niz[i].l], poj[niz[i].r], poj[niz[i].x], niz[i].w};
      |     ^~
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:93:5: note: in expansion of macro 'ff'
   93 |     ff(i,1,n)sejv[i] = dp[i];
      |     ^~
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:94:5: note: in expansion of macro 'ff'
   94 |     ff(i,1,n){
      |     ^~
pinball.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
pinball.cpp:102:5: note: in expansion of macro 'ff'
  102 |     ff(i,1,n){
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...