# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
411199 |
2021-05-24T16:24:32 Z |
cpp219 |
Pinball (JOI14_pinball) |
C++14 |
|
10 ms |
13132 KB |
#pragma GCC optimization "O2"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 1e5 + 9;
const ll Log2 = 20;
const ll inf = 1e16 + 7;
typedef pair<ll,ll> LL;
struct Seg{
ll L,R,to,val;
};
Seg a[N];
ll m,n,L,R,to,val,st[2][4*N],ans = inf;
void upd(ll cond,ll id,ll l,ll r,ll u,ll val){
if (u < l||r < u) return;
if (l == r){
st[cond][id] = min(st[cond][id],val); return;
}
ll mid = (l + r)/2;
upd(cond,id*2,l,mid,u,val); upd(cond,id*2 + 1,mid + 1,r,u,val);
st[cond][id] = min(st[cond][id*2],st[cond][id*2 + 1]);
}
ll Get(ll cond,ll id,ll l,ll r,ll u,ll v){
if (v < l||r < u) return inf;
if (u <= l&&r <= v) return st[cond][id];
ll mid = (l + r)/2;
return min(Get(cond,id*2,l,mid,u,v),Get(cond,id*2 + 1,mid + 1,r,u,v));
}
/// 0 for L 1 for R
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define task "tst"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
}
for (ll i = 1;i < 4*N;i++) st[0][i] = st[1][i] = inf;
cin>>m>>n;
for (ll i = 1;i <= m;i++){
cin>>L>>R>>to>>val;
ll v1 = Get(0,1,1,n,L,R),v2 = Get(1,1,1,n,L,R);
if (L == 1) v1 = 0;
if (R == n) v2 = 0;
ans = min(ans,v1 + v2 + val);
upd(0,1,1,n,to,v1 + val); upd(1,1,1,n,to,v2 + val);
}
if (ans != inf) cout<<ans;
else cout<<-1;
}
Compilation message
pinball.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
1 | #pragma GCC optimization "O2"
|
pinball.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization "unroll-loop"
|
pinball.cpp: In function 'int main()':
pinball.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6544 KB |
Output is correct |
2 |
Correct |
4 ms |
6556 KB |
Output is correct |
3 |
Correct |
4 ms |
6476 KB |
Output is correct |
4 |
Correct |
5 ms |
6524 KB |
Output is correct |
5 |
Correct |
4 ms |
6476 KB |
Output is correct |
6 |
Correct |
4 ms |
6476 KB |
Output is correct |
7 |
Correct |
4 ms |
6476 KB |
Output is correct |
8 |
Correct |
4 ms |
6584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6544 KB |
Output is correct |
2 |
Correct |
4 ms |
6556 KB |
Output is correct |
3 |
Correct |
4 ms |
6476 KB |
Output is correct |
4 |
Correct |
5 ms |
6524 KB |
Output is correct |
5 |
Correct |
4 ms |
6476 KB |
Output is correct |
6 |
Correct |
4 ms |
6476 KB |
Output is correct |
7 |
Correct |
4 ms |
6476 KB |
Output is correct |
8 |
Correct |
4 ms |
6584 KB |
Output is correct |
9 |
Runtime error |
10 ms |
13132 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6544 KB |
Output is correct |
2 |
Correct |
4 ms |
6556 KB |
Output is correct |
3 |
Correct |
4 ms |
6476 KB |
Output is correct |
4 |
Correct |
5 ms |
6524 KB |
Output is correct |
5 |
Correct |
4 ms |
6476 KB |
Output is correct |
6 |
Correct |
4 ms |
6476 KB |
Output is correct |
7 |
Correct |
4 ms |
6476 KB |
Output is correct |
8 |
Correct |
4 ms |
6584 KB |
Output is correct |
9 |
Runtime error |
10 ms |
13132 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6544 KB |
Output is correct |
2 |
Correct |
4 ms |
6556 KB |
Output is correct |
3 |
Correct |
4 ms |
6476 KB |
Output is correct |
4 |
Correct |
5 ms |
6524 KB |
Output is correct |
5 |
Correct |
4 ms |
6476 KB |
Output is correct |
6 |
Correct |
4 ms |
6476 KB |
Output is correct |
7 |
Correct |
4 ms |
6476 KB |
Output is correct |
8 |
Correct |
4 ms |
6584 KB |
Output is correct |
9 |
Runtime error |
10 ms |
13132 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |