답안 #333006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333006 2020-12-04T08:44:52 Z Dymo Bootfall (IZhO17_bootfall) C++14
100 / 100
219 ms 2924 KB
#include<bits/stdc++.h>
using namespace std;


#define pb    push_back
#define eb   emplace_back
#define ll  int
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=500*500+10;
const ll mod =1e9+7 ;
const ll base=1e18;
const ll block=1000;
/// con 0 ngay nua
/// zesitahn
ll a[maxn];
bitset<maxn> st1;
ll t=0;
void dosth(ll l,ll r,bitset<maxn> st)
{
    if (l==r)
    {
        bitset<maxn>chk;
         for (int i=1;i<maxn;i++)
         {
           ll cl=t-a[l]-i;
           if (cl<0) break;
           if (cl%2==0)
           {
               cl/=2;

               if (st[cl]==1) chk[i]=1;
           }
         }
         st1&=chk;
         return ;
    }
    ll mid=(l+r)/2;
    auto nxt=st;
    for (int i=mid+1;i<=r;i++)
    {
        nxt|=(nxt<<a[i]);
    }
    dosth(l,mid,nxt);
    nxt=st;
    for (int i=l;i<=mid;i++)
    {
        nxt|=(nxt<<a[i]);
    }
    dosth(mid+1, r, nxt);
}
bool chk(ll n)
{
   if (t%2==1) return false;
   bitset<maxn> st;
   st[0]=1;
   for (int i=1;i<=n;i++)
   {
       st|=(st<<a[i]);
   }
 //  cout <<t/2<<endl;
   return st[t/2];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("queue.inp", "r"))
    {
        freopen("queue.inp", "r", stdin);
        freopen("queue.out", "w", stdout);
    }
    ll n;
     cin>> n;
     for (int i=1;i<=n;i++)
     {
         cin>>a[i];
         t+=a[i];
     }
     if (!chk(n))
     {
         cout <<0;
         return 0;
     }
     bitset<maxn> st;
     st[0]=1;
     for (int i=1;i<maxn;i++)
     {
         st1[i]=1;
     }
     dosth(1,n,st);
     vector<ll> ans;
     for (int i=1;i<maxn;i++)
     {
         if (st1[i]) ans.pb(i);
     }
     cout <<ans.size()<<endl;
     for (auto to:ans)
     {
         cout <<to<<" ";
     }

}

Compilation message

bootfall.cpp:14:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   14 | const ll base=1e18;
      |               ^~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   73 |         freopen("queue.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   74 |         freopen("queue.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 1004 KB Output is correct
11 Correct 4 ms 1004 KB Output is correct
12 Correct 5 ms 1004 KB Output is correct
13 Correct 4 ms 1004 KB Output is correct
14 Correct 4 ms 1132 KB Output is correct
15 Correct 4 ms 1004 KB Output is correct
16 Correct 4 ms 1004 KB Output is correct
17 Correct 3 ms 1004 KB Output is correct
18 Correct 4 ms 1004 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 5 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 1004 KB Output is correct
11 Correct 4 ms 1004 KB Output is correct
12 Correct 5 ms 1004 KB Output is correct
13 Correct 4 ms 1004 KB Output is correct
14 Correct 4 ms 1132 KB Output is correct
15 Correct 4 ms 1004 KB Output is correct
16 Correct 4 ms 1004 KB Output is correct
17 Correct 3 ms 1004 KB Output is correct
18 Correct 4 ms 1004 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 5 ms 1004 KB Output is correct
21 Correct 8 ms 1280 KB Output is correct
22 Correct 9 ms 1388 KB Output is correct
23 Correct 6 ms 1260 KB Output is correct
24 Correct 11 ms 1388 KB Output is correct
25 Correct 11 ms 1388 KB Output is correct
26 Correct 13 ms 1388 KB Output is correct
27 Correct 12 ms 1388 KB Output is correct
28 Correct 12 ms 1388 KB Output is correct
29 Correct 13 ms 1260 KB Output is correct
30 Correct 12 ms 1260 KB Output is correct
31 Correct 12 ms 1388 KB Output is correct
32 Correct 11 ms 1388 KB Output is correct
33 Correct 12 ms 1260 KB Output is correct
34 Correct 15 ms 1260 KB Output is correct
35 Correct 12 ms 1260 KB Output is correct
36 Correct 11 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 1004 KB Output is correct
11 Correct 4 ms 1004 KB Output is correct
12 Correct 5 ms 1004 KB Output is correct
13 Correct 4 ms 1004 KB Output is correct
14 Correct 4 ms 1132 KB Output is correct
15 Correct 4 ms 1004 KB Output is correct
16 Correct 4 ms 1004 KB Output is correct
17 Correct 3 ms 1004 KB Output is correct
18 Correct 4 ms 1004 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 5 ms 1004 KB Output is correct
21 Correct 8 ms 1280 KB Output is correct
22 Correct 9 ms 1388 KB Output is correct
23 Correct 6 ms 1260 KB Output is correct
24 Correct 11 ms 1388 KB Output is correct
25 Correct 11 ms 1388 KB Output is correct
26 Correct 13 ms 1388 KB Output is correct
27 Correct 12 ms 1388 KB Output is correct
28 Correct 12 ms 1388 KB Output is correct
29 Correct 13 ms 1260 KB Output is correct
30 Correct 12 ms 1260 KB Output is correct
31 Correct 12 ms 1388 KB Output is correct
32 Correct 11 ms 1388 KB Output is correct
33 Correct 12 ms 1260 KB Output is correct
34 Correct 15 ms 1260 KB Output is correct
35 Correct 12 ms 1260 KB Output is correct
36 Correct 11 ms 1388 KB Output is correct
37 Correct 29 ms 1644 KB Output is correct
38 Correct 29 ms 1644 KB Output is correct
39 Correct 50 ms 1388 KB Output is correct
40 Correct 41 ms 1772 KB Output is correct
41 Correct 59 ms 1536 KB Output is correct
42 Correct 37 ms 1644 KB Output is correct
43 Correct 45 ms 1784 KB Output is correct
44 Correct 46 ms 1772 KB Output is correct
45 Correct 47 ms 1772 KB Output is correct
46 Correct 41 ms 1516 KB Output is correct
47 Correct 38 ms 1644 KB Output is correct
48 Correct 49 ms 1772 KB Output is correct
49 Correct 50 ms 1516 KB Output is correct
50 Correct 39 ms 1644 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 56 ms 2028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 1004 KB Output is correct
11 Correct 4 ms 1004 KB Output is correct
12 Correct 5 ms 1004 KB Output is correct
13 Correct 4 ms 1004 KB Output is correct
14 Correct 4 ms 1132 KB Output is correct
15 Correct 4 ms 1004 KB Output is correct
16 Correct 4 ms 1004 KB Output is correct
17 Correct 3 ms 1004 KB Output is correct
18 Correct 4 ms 1004 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 5 ms 1004 KB Output is correct
21 Correct 8 ms 1280 KB Output is correct
22 Correct 9 ms 1388 KB Output is correct
23 Correct 6 ms 1260 KB Output is correct
24 Correct 11 ms 1388 KB Output is correct
25 Correct 11 ms 1388 KB Output is correct
26 Correct 13 ms 1388 KB Output is correct
27 Correct 12 ms 1388 KB Output is correct
28 Correct 12 ms 1388 KB Output is correct
29 Correct 13 ms 1260 KB Output is correct
30 Correct 12 ms 1260 KB Output is correct
31 Correct 12 ms 1388 KB Output is correct
32 Correct 11 ms 1388 KB Output is correct
33 Correct 12 ms 1260 KB Output is correct
34 Correct 15 ms 1260 KB Output is correct
35 Correct 12 ms 1260 KB Output is correct
36 Correct 11 ms 1388 KB Output is correct
37 Correct 29 ms 1644 KB Output is correct
38 Correct 29 ms 1644 KB Output is correct
39 Correct 50 ms 1388 KB Output is correct
40 Correct 41 ms 1772 KB Output is correct
41 Correct 59 ms 1536 KB Output is correct
42 Correct 37 ms 1644 KB Output is correct
43 Correct 45 ms 1784 KB Output is correct
44 Correct 46 ms 1772 KB Output is correct
45 Correct 47 ms 1772 KB Output is correct
46 Correct 41 ms 1516 KB Output is correct
47 Correct 38 ms 1644 KB Output is correct
48 Correct 49 ms 1772 KB Output is correct
49 Correct 50 ms 1516 KB Output is correct
50 Correct 39 ms 1644 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 56 ms 2028 KB Output is correct
53 Correct 52 ms 1900 KB Output is correct
54 Correct 67 ms 1900 KB Output is correct
55 Correct 92 ms 2160 KB Output is correct
56 Correct 57 ms 1900 KB Output is correct
57 Correct 94 ms 2160 KB Output is correct
58 Correct 69 ms 2028 KB Output is correct
59 Correct 75 ms 2088 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 81 ms 2160 KB Output is correct
62 Correct 78 ms 2160 KB Output is correct
63 Correct 81 ms 2160 KB Output is correct
64 Correct 80 ms 2160 KB Output is correct
65 Correct 60 ms 1644 KB Output is correct
66 Correct 60 ms 1772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 1004 KB Output is correct
11 Correct 4 ms 1004 KB Output is correct
12 Correct 5 ms 1004 KB Output is correct
13 Correct 4 ms 1004 KB Output is correct
14 Correct 4 ms 1132 KB Output is correct
15 Correct 4 ms 1004 KB Output is correct
16 Correct 4 ms 1004 KB Output is correct
17 Correct 3 ms 1004 KB Output is correct
18 Correct 4 ms 1004 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 5 ms 1004 KB Output is correct
21 Correct 8 ms 1280 KB Output is correct
22 Correct 9 ms 1388 KB Output is correct
23 Correct 6 ms 1260 KB Output is correct
24 Correct 11 ms 1388 KB Output is correct
25 Correct 11 ms 1388 KB Output is correct
26 Correct 13 ms 1388 KB Output is correct
27 Correct 12 ms 1388 KB Output is correct
28 Correct 12 ms 1388 KB Output is correct
29 Correct 13 ms 1260 KB Output is correct
30 Correct 12 ms 1260 KB Output is correct
31 Correct 12 ms 1388 KB Output is correct
32 Correct 11 ms 1388 KB Output is correct
33 Correct 12 ms 1260 KB Output is correct
34 Correct 15 ms 1260 KB Output is correct
35 Correct 12 ms 1260 KB Output is correct
36 Correct 11 ms 1388 KB Output is correct
37 Correct 29 ms 1644 KB Output is correct
38 Correct 29 ms 1644 KB Output is correct
39 Correct 50 ms 1388 KB Output is correct
40 Correct 41 ms 1772 KB Output is correct
41 Correct 59 ms 1536 KB Output is correct
42 Correct 37 ms 1644 KB Output is correct
43 Correct 45 ms 1784 KB Output is correct
44 Correct 46 ms 1772 KB Output is correct
45 Correct 47 ms 1772 KB Output is correct
46 Correct 41 ms 1516 KB Output is correct
47 Correct 38 ms 1644 KB Output is correct
48 Correct 49 ms 1772 KB Output is correct
49 Correct 50 ms 1516 KB Output is correct
50 Correct 39 ms 1644 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 56 ms 2028 KB Output is correct
53 Correct 52 ms 1900 KB Output is correct
54 Correct 67 ms 1900 KB Output is correct
55 Correct 92 ms 2160 KB Output is correct
56 Correct 57 ms 1900 KB Output is correct
57 Correct 94 ms 2160 KB Output is correct
58 Correct 69 ms 2028 KB Output is correct
59 Correct 75 ms 2088 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 81 ms 2160 KB Output is correct
62 Correct 78 ms 2160 KB Output is correct
63 Correct 81 ms 2160 KB Output is correct
64 Correct 80 ms 2160 KB Output is correct
65 Correct 60 ms 1644 KB Output is correct
66 Correct 60 ms 1772 KB Output is correct
67 Correct 92 ms 2032 KB Output is correct
68 Correct 5 ms 492 KB Output is correct
69 Correct 201 ms 2796 KB Output is correct
70 Correct 142 ms 2416 KB Output is correct
71 Correct 145 ms 2288 KB Output is correct
72 Correct 132 ms 1516 KB Output is correct
73 Correct 134 ms 1516 KB Output is correct
74 Correct 203 ms 2796 KB Output is correct
75 Correct 170 ms 2540 KB Output is correct
76 Correct 219 ms 2796 KB Output is correct
77 Correct 214 ms 2924 KB Output is correct