Submission #1077631

# Submission time Handle Problem Language Result Execution time Memory
1077631 2024-08-27T08:26:36 Z vjudge1 Council (JOI23_council) C++
56 / 100
4000 ms 21692 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
const ll M=2e6+10;
const ll inf=2e18+10;
const ll mod=1e9+7;
ll n,m,a[M],cnt[M],cntb[40],ans[M];
int main() {
  ios_base::sync_with_stdio(0),cin.tie(0);
  cin>>n>>m;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) {
      ll x;
      cin>>x;
      a[i]+=(x*(1<<j));
      cntb[j]+=x;
    }
  for(int i=0;i<n;i++) {
    for(int j=a[i];j<(1<<m);j++,j|=a[i]) {
      cnt[j]++;
    }
  }
  for(int i=0;i<(1<<m);i++)
    ans[i]=-1;
  for(int i=0;i<n;i++) {
    ll res=0,x=0;
    for(int j=0;j<m;j++) {
      if(cntb[j]-bool(((1<<j)&a[i])>0)>n/2)
        res++;
      else if(cntb[j]-bool(((1<<j)&a[i])>0)==n/2) {
        x+=(1<<j);
      }
    }
    if(ans[x]>-1) {
      cout<<ans[x]<<'\n';
      continue;
    }
    ll res1=0;
    for(int j=x;j>=0;j--) {
      if(j<0)
        break;
      j&=x;
      ll y=j+(((1<<m)-1)^x);
      if((a[i]&y)==a[i])
        cnt[y]--;
      if(cnt[y]>0)
        res1=max(res1,(ll)__builtin_popcountll(x)-__builtin_popcountll(j));
      if((a[i]&y)==a[i])
        cnt[y]++;
    }
    ans[x]=res1+res;
    cout<<res1+res<<'\n';
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 41 ms 18916 KB Output is correct
6 Correct 2 ms 14936 KB Output is correct
7 Correct 2 ms 21084 KB Output is correct
8 Correct 3 ms 21084 KB Output is correct
9 Correct 4 ms 21084 KB Output is correct
10 Correct 3 ms 21084 KB Output is correct
11 Correct 3 ms 21084 KB Output is correct
12 Correct 8 ms 21172 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4564 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4440 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4440 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4560 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4556 KB Output is correct
44 Correct 1 ms 4700 KB Output is correct
45 Correct 1 ms 4568 KB Output is correct
46 Correct 5 ms 8796 KB Output is correct
47 Correct 1 ms 8792 KB Output is correct
48 Correct 1 ms 8792 KB Output is correct
49 Correct 1 ms 8796 KB Output is correct
50 Correct 1 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 41 ms 18916 KB Output is correct
6 Correct 2 ms 14936 KB Output is correct
7 Correct 2 ms 21084 KB Output is correct
8 Correct 3 ms 21084 KB Output is correct
9 Correct 4 ms 21084 KB Output is correct
10 Correct 3 ms 21084 KB Output is correct
11 Correct 3 ms 21084 KB Output is correct
12 Correct 8 ms 21172 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4564 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4440 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4440 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4560 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4556 KB Output is correct
44 Correct 1 ms 4700 KB Output is correct
45 Correct 1 ms 4568 KB Output is correct
46 Correct 5 ms 8796 KB Output is correct
47 Correct 1 ms 8792 KB Output is correct
48 Correct 1 ms 8792 KB Output is correct
49 Correct 1 ms 8796 KB Output is correct
50 Correct 1 ms 8796 KB Output is correct
51 Correct 4 ms 14936 KB Output is correct
52 Correct 2256 ms 21060 KB Output is correct
53 Correct 18 ms 21064 KB Output is correct
54 Correct 63 ms 21080 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 19 ms 8952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 34 ms 8356 KB Output is correct
3 Correct 34 ms 8276 KB Output is correct
4 Correct 27 ms 7740 KB Output is correct
5 Correct 52 ms 8276 KB Output is correct
6 Correct 37 ms 7764 KB Output is correct
7 Correct 48 ms 8272 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 34 ms 8356 KB Output is correct
3 Correct 34 ms 8276 KB Output is correct
4 Correct 27 ms 7740 KB Output is correct
5 Correct 52 ms 8276 KB Output is correct
6 Correct 37 ms 7764 KB Output is correct
7 Correct 48 ms 8272 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4564 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 137 ms 12584 KB Output is correct
21 Correct 127 ms 12116 KB Output is correct
22 Correct 122 ms 12120 KB Output is correct
23 Correct 132 ms 12884 KB Output is correct
24 Correct 340 ms 12680 KB Output is correct
25 Correct 141 ms 12372 KB Output is correct
26 Correct 145 ms 12368 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 34 ms 8356 KB Output is correct
3 Correct 34 ms 8276 KB Output is correct
4 Correct 27 ms 7740 KB Output is correct
5 Correct 52 ms 8276 KB Output is correct
6 Correct 37 ms 7764 KB Output is correct
7 Correct 48 ms 8272 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4564 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 137 ms 12584 KB Output is correct
21 Correct 127 ms 12116 KB Output is correct
22 Correct 122 ms 12120 KB Output is correct
23 Correct 132 ms 12884 KB Output is correct
24 Correct 340 ms 12680 KB Output is correct
25 Correct 141 ms 12372 KB Output is correct
26 Correct 145 ms 12368 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4440 KB Output is correct
47 Correct 209 ms 14892 KB Output is correct
48 Correct 187 ms 14416 KB Output is correct
49 Correct 192 ms 14420 KB Output is correct
50 Correct 148 ms 15184 KB Output is correct
51 Correct 3709 ms 14792 KB Output is correct
52 Correct 287 ms 14928 KB Output is correct
53 Correct 316 ms 15184 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 0 ms 604 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 34 ms 8356 KB Output is correct
3 Correct 34 ms 8276 KB Output is correct
4 Correct 27 ms 7740 KB Output is correct
5 Correct 52 ms 8276 KB Output is correct
6 Correct 37 ms 7764 KB Output is correct
7 Correct 48 ms 8272 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4564 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 137 ms 12584 KB Output is correct
21 Correct 127 ms 12116 KB Output is correct
22 Correct 122 ms 12120 KB Output is correct
23 Correct 132 ms 12884 KB Output is correct
24 Correct 340 ms 12680 KB Output is correct
25 Correct 141 ms 12372 KB Output is correct
26 Correct 145 ms 12368 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4440 KB Output is correct
47 Correct 209 ms 14892 KB Output is correct
48 Correct 187 ms 14416 KB Output is correct
49 Correct 192 ms 14420 KB Output is correct
50 Correct 148 ms 15184 KB Output is correct
51 Correct 3709 ms 14792 KB Output is correct
52 Correct 287 ms 14928 KB Output is correct
53 Correct 316 ms 15184 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 0 ms 604 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 1 ms 4700 KB Output is correct
59 Correct 244 ms 18260 KB Output is correct
60 Correct 650 ms 12964 KB Output is correct
61 Correct 712 ms 13124 KB Output is correct
62 Correct 776 ms 13392 KB Output is correct
63 Correct 275 ms 18772 KB Output is correct
64 Correct 384 ms 21332 KB Output is correct
65 Correct 380 ms 21328 KB Output is correct
66 Correct 181 ms 21692 KB Output is correct
67 Execution timed out 4075 ms 18520 KB Time limit exceeded
68 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 41 ms 18916 KB Output is correct
6 Correct 2 ms 14936 KB Output is correct
7 Correct 2 ms 21084 KB Output is correct
8 Correct 3 ms 21084 KB Output is correct
9 Correct 4 ms 21084 KB Output is correct
10 Correct 3 ms 21084 KB Output is correct
11 Correct 3 ms 21084 KB Output is correct
12 Correct 8 ms 21172 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4564 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4440 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4440 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4560 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4556 KB Output is correct
44 Correct 1 ms 4700 KB Output is correct
45 Correct 1 ms 4568 KB Output is correct
46 Correct 5 ms 8796 KB Output is correct
47 Correct 1 ms 8792 KB Output is correct
48 Correct 1 ms 8792 KB Output is correct
49 Correct 1 ms 8796 KB Output is correct
50 Correct 1 ms 8796 KB Output is correct
51 Correct 4 ms 14936 KB Output is correct
52 Correct 2256 ms 21060 KB Output is correct
53 Correct 18 ms 21064 KB Output is correct
54 Correct 63 ms 21080 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 19 ms 8952 KB Output is correct
57 Correct 1 ms 4440 KB Output is correct
58 Correct 34 ms 8356 KB Output is correct
59 Correct 34 ms 8276 KB Output is correct
60 Correct 27 ms 7740 KB Output is correct
61 Correct 52 ms 8276 KB Output is correct
62 Correct 37 ms 7764 KB Output is correct
63 Correct 48 ms 8272 KB Output is correct
64 Correct 1 ms 4444 KB Output is correct
65 Correct 1 ms 4444 KB Output is correct
66 Correct 1 ms 4444 KB Output is correct
67 Correct 1 ms 4444 KB Output is correct
68 Correct 1 ms 4444 KB Output is correct
69 Correct 1 ms 4444 KB Output is correct
70 Correct 1 ms 4444 KB Output is correct
71 Correct 1 ms 4444 KB Output is correct
72 Correct 1 ms 4444 KB Output is correct
73 Correct 1 ms 4564 KB Output is correct
74 Correct 1 ms 4444 KB Output is correct
75 Correct 1 ms 4444 KB Output is correct
76 Correct 137 ms 12584 KB Output is correct
77 Correct 127 ms 12116 KB Output is correct
78 Correct 122 ms 12120 KB Output is correct
79 Correct 132 ms 12884 KB Output is correct
80 Correct 340 ms 12680 KB Output is correct
81 Correct 141 ms 12372 KB Output is correct
82 Correct 145 ms 12368 KB Output is correct
83 Correct 1 ms 4444 KB Output is correct
84 Correct 1 ms 4444 KB Output is correct
85 Correct 1 ms 4444 KB Output is correct
86 Correct 1 ms 4444 KB Output is correct
87 Correct 1 ms 4440 KB Output is correct
88 Correct 1 ms 4444 KB Output is correct
89 Correct 1 ms 4444 KB Output is correct
90 Correct 1 ms 4440 KB Output is correct
91 Correct 1 ms 4444 KB Output is correct
92 Correct 1 ms 4444 KB Output is correct
93 Correct 1 ms 4444 KB Output is correct
94 Correct 1 ms 4444 KB Output is correct
95 Correct 1 ms 4444 KB Output is correct
96 Correct 1 ms 4444 KB Output is correct
97 Correct 1 ms 4444 KB Output is correct
98 Correct 1 ms 4444 KB Output is correct
99 Correct 1 ms 4444 KB Output is correct
100 Correct 1 ms 4444 KB Output is correct
101 Correct 1 ms 4444 KB Output is correct
102 Correct 1 ms 4440 KB Output is correct
103 Correct 209 ms 14892 KB Output is correct
104 Correct 187 ms 14416 KB Output is correct
105 Correct 192 ms 14420 KB Output is correct
106 Correct 148 ms 15184 KB Output is correct
107 Correct 3709 ms 14792 KB Output is correct
108 Correct 287 ms 14928 KB Output is correct
109 Correct 316 ms 15184 KB Output is correct
110 Correct 1 ms 4444 KB Output is correct
111 Correct 1 ms 604 KB Output is correct
112 Correct 0 ms 604 KB Output is correct
113 Correct 1 ms 4444 KB Output is correct
114 Correct 1 ms 4700 KB Output is correct
115 Correct 244 ms 18260 KB Output is correct
116 Correct 650 ms 12964 KB Output is correct
117 Correct 712 ms 13124 KB Output is correct
118 Correct 776 ms 13392 KB Output is correct
119 Correct 275 ms 18772 KB Output is correct
120 Correct 384 ms 21332 KB Output is correct
121 Correct 380 ms 21328 KB Output is correct
122 Correct 181 ms 21692 KB Output is correct
123 Execution timed out 4075 ms 18520 KB Time limit exceeded
124 Halted 0 ms 0 KB -