# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
735135 | 2023-05-03T15:29:14 Z | ReLice | Bali Sculptures (APIO15_sculpture) | C++14 | 1000 ms | 21068 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define endl "\n" #define fr first #define sc second #define sz size() #define bc back() using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}*/ void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e9+7; const ll mod=1e9+7; const ll N=2e3+7; ll pref[N],n,l,r; vector<vector<ll> > g(N); ll vis[N]; ll d[N]; bool check(ll val){ set <pair<ll,ll>> q; q.insert({0,1}); for(ll i=1;i<=n+1;i++) d[i]=inf; d[1]=0; while(!q.empty()){ ll x=q.begin()->sc; q.erase(q.begin()); for(auto i : g[x]){ if((pref[i]-pref[x-1]) & (1ll<<val)) continue; if(d[x]+1<d[i+1]){ d[i+1]=d[x]+1; q.insert({d[i+1],i+1}); } } } ll l1=d[n+1],r1; q.insert({0,1}); for(ll i=1;i<=n+1;i++) d[i]=inf; d[1]=0; while(!q.empty()){ ll x=q.begin()->sc; q.erase(q.begin()); for(auto i : g[x]){ if((pref[i]-pref[x-1]) & (1ll<<val)) continue; if(d[x]-1<d[i+1]){ d[i+1]=d[x]-1; q.insert({d[i+1],i+1}); } } } r1=-d[n+1]; if(r1<l || l1>r || l1==inf || r1==inf) return false; else return true; } void ers(ll val){ for(ll i=1;i<=n;i++){ for(ll j=0;j<g[i].sz;j++){ if((pref[g[i][j]]-pref[i-1]) & (1ll<<val)){ swap(g[i][j],g[i].bc); g[i].pop_back(); j--; } } } } void solve(){ ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t; ll k; cin>>n>>l>>r; vector <ll> v; v.pb(0); for(i=0;i<n;i++){ cin>>b; v.pb(b); } for(i=1;i<=n;i++){ pref[i]=pref[i-1]+v[i]; } for(i=1;i<=n;i++){ for(j=i;j<=n;j++){ g[i].pb(j); } } for(i=45;i>=0;i--){ if(check(i)){ ers(i); } else{ ans+=(1ll<<i); } } cout<<ans<<endl; } signed main(){ //start(); //fre(""); ll t=1; //cin>>t; while(t--) solve(); } /* 6 1 3 8 1 2 1 5 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 352 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 2 ms | 340 KB | Output is correct |
9 | Correct | 2 ms | 288 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 2 ms | 356 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 468 KB | Output is correct |
19 | Correct | 1 ms | 356 KB | Output is correct |
20 | Correct | 2 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 352 KB | Output is correct |
22 | Correct | 2 ms | 260 KB | Output is correct |
23 | Correct | 2 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 2 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 356 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 2 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 2 ms | 360 KB | Output is correct |
36 | Correct | 2 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 356 KB | Output is correct |
4 | Correct | 1 ms | 356 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 2 ms | 340 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 2 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 2 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 2 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 352 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 6 ms | 348 KB | Output is correct |
30 | Correct | 8 ms | 340 KB | Output is correct |
31 | Correct | 10 ms | 468 KB | Output is correct |
32 | Correct | 8 ms | 448 KB | Output is correct |
33 | Correct | 9 ms | 340 KB | Output is correct |
34 | Correct | 8 ms | 340 KB | Output is correct |
35 | Correct | 9 ms | 356 KB | Output is correct |
36 | Correct | 8 ms | 356 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 356 KB | Output is correct |
8 | Correct | 2 ms | 356 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 352 KB | Output is correct |
13 | Correct | 2 ms | 340 KB | Output is correct |
14 | Correct | 2 ms | 352 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 340 KB | Output is correct |
17 | Correct | 6 ms | 356 KB | Output is correct |
18 | Correct | 7 ms | 340 KB | Output is correct |
19 | Correct | 8 ms | 448 KB | Output is correct |
20 | Correct | 11 ms | 452 KB | Output is correct |
21 | Correct | 8 ms | 340 KB | Output is correct |
22 | Correct | 8 ms | 360 KB | Output is correct |
23 | Correct | 9 ms | 340 KB | Output is correct |
24 | Correct | 9 ms | 340 KB | Output is correct |
25 | Correct | 18 ms | 468 KB | Output is correct |
26 | Correct | 20 ms | 468 KB | Output is correct |
27 | Correct | 27 ms | 596 KB | Output is correct |
28 | Correct | 32 ms | 596 KB | Output is correct |
29 | Correct | 30 ms | 724 KB | Output is correct |
30 | Correct | 33 ms | 596 KB | Output is correct |
31 | Correct | 32 ms | 616 KB | Output is correct |
32 | Correct | 35 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 352 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 352 KB | Output is correct |
8 | Correct | 2 ms | 340 KB | Output is correct |
9 | Correct | 2 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 356 KB | Output is correct |
12 | Correct | 2 ms | 288 KB | Output is correct |
13 | Correct | 2 ms | 352 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 356 KB | Output is correct |
22 | Correct | 2 ms | 288 KB | Output is correct |
23 | Correct | 2 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 2 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 356 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 256 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 356 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
33 | Correct | 2 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 2 ms | 340 KB | Output is correct |
38 | Correct | 2 ms | 352 KB | Output is correct |
39 | Correct | 5 ms | 356 KB | Output is correct |
40 | Correct | 6 ms | 340 KB | Output is correct |
41 | Correct | 10 ms | 340 KB | Output is correct |
42 | Correct | 7 ms | 360 KB | Output is correct |
43 | Correct | 8 ms | 340 KB | Output is correct |
44 | Correct | 10 ms | 452 KB | Output is correct |
45 | Correct | 9 ms | 340 KB | Output is correct |
46 | Correct | 8 ms | 448 KB | Output is correct |
47 | Correct | 9 ms | 456 KB | Output is correct |
48 | Correct | 14 ms | 468 KB | Output is correct |
49 | Correct | 19 ms | 580 KB | Output is correct |
50 | Correct | 27 ms | 616 KB | Output is correct |
51 | Correct | 32 ms | 596 KB | Output is correct |
52 | Correct | 40 ms | 704 KB | Output is correct |
53 | Correct | 36 ms | 704 KB | Output is correct |
54 | Correct | 34 ms | 596 KB | Output is correct |
55 | Correct | 34 ms | 700 KB | Output is correct |
56 | Correct | 3 ms | 340 KB | Output is correct |
57 | Correct | 7 ms | 468 KB | Output is correct |
58 | Correct | 9 ms | 596 KB | Output is correct |
59 | Correct | 11 ms | 724 KB | Output is correct |
60 | Correct | 10 ms | 836 KB | Output is correct |
61 | Correct | 12 ms | 596 KB | Output is correct |
62 | Correct | 14 ms | 728 KB | Output is correct |
63 | Correct | 17 ms | 728 KB | Output is correct |
64 | Correct | 31 ms | 608 KB | Output is correct |
65 | Correct | 5 ms | 448 KB | Output is correct |
66 | Correct | 8 ms | 484 KB | Output is correct |
67 | Correct | 8 ms | 468 KB | Output is correct |
68 | Correct | 10 ms | 596 KB | Output is correct |
69 | Correct | 12 ms | 720 KB | Output is correct |
70 | Correct | 10 ms | 612 KB | Output is correct |
71 | Correct | 11 ms | 724 KB | Output is correct |
72 | Correct | 13 ms | 724 KB | Output is correct |
73 | Correct | 13 ms | 596 KB | Output is correct |
74 | Correct | 13 ms | 724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 356 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 2 ms | 352 KB | Output is correct |
9 | Correct | 2 ms | 352 KB | Output is correct |
10 | Correct | 3 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 2 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 356 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 356 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 356 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 2 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 356 KB | Output is correct |
25 | Correct | 2 ms | 340 KB | Output is correct |
26 | Correct | 5 ms | 340 KB | Output is correct |
27 | Correct | 6 ms | 340 KB | Output is correct |
28 | Correct | 8 ms | 340 KB | Output is correct |
29 | Correct | 10 ms | 340 KB | Output is correct |
30 | Correct | 9 ms | 440 KB | Output is correct |
31 | Correct | 11 ms | 444 KB | Output is correct |
32 | Correct | 10 ms | 420 KB | Output is correct |
33 | Correct | 9 ms | 340 KB | Output is correct |
34 | Correct | 9 ms | 360 KB | Output is correct |
35 | Correct | 13 ms | 488 KB | Output is correct |
36 | Correct | 18 ms | 620 KB | Output is correct |
37 | Correct | 29 ms | 764 KB | Output is correct |
38 | Correct | 34 ms | 724 KB | Output is correct |
39 | Correct | 34 ms | 724 KB | Output is correct |
40 | Correct | 35 ms | 704 KB | Output is correct |
41 | Correct | 33 ms | 596 KB | Output is correct |
42 | Correct | 34 ms | 724 KB | Output is correct |
43 | Correct | 3 ms | 360 KB | Output is correct |
44 | Correct | 7 ms | 468 KB | Output is correct |
45 | Correct | 9 ms | 664 KB | Output is correct |
46 | Correct | 12 ms | 724 KB | Output is correct |
47 | Correct | 11 ms | 724 KB | Output is correct |
48 | Correct | 11 ms | 612 KB | Output is correct |
49 | Correct | 13 ms | 724 KB | Output is correct |
50 | Correct | 12 ms | 608 KB | Output is correct |
51 | Correct | 11 ms | 608 KB | Output is correct |
52 | Correct | 653 ms | 12688 KB | Output is correct |
53 | Execution timed out | 1082 ms | 21068 KB | Time limit exceeded |
54 | Halted | 0 ms | 0 KB | - |