Submission #1077644

# Submission time Handle Problem Language Result Execution time Memory
1077644 2024-08-27T08:29:16 Z vjudge1 Council (JOI23_council) C++
56 / 100
4000 ms 12892 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vii;
typedef pair<int,int> pii;
#define F first
#define S second
#define aint(v) v.begin(),v.end()
#define pb push_back
const int M=2e6+10;
const int inf=2e18+10;
const int mod=1e9+7;
int 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++) {
      int 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++) {
    int 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;
    }
    int res1=0;
    for(int j=x;j>=0;j--) {
      if(j<0)
        break;
      j&=x;
      int y=j+(((1<<m)-1)^x);
      if((a[i]&y)==a[i])
        cnt[y]--;
      if(cnt[y]>0)
        res1=max(res1,__builtin_popcount(x)-__builtin_popcount(j));
      if((a[i]&y)==a[i])
        cnt[y]++;
    }
    ans[x]=res1+res;
    cout<<res1+res<<'\n';
  }
}

Compilation message

council.cpp:11:19: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+18' to '2147483647' [-Woverflow]
   11 | const int inf=2e18+10;
      |               ~~~~^~~
# 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 40 ms 12764 KB Output is correct
6 Correct 2 ms 10840 KB Output is correct
7 Correct 2 ms 12888 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 2 ms 12892 KB Output is correct
11 Correct 2 ms 12892 KB Output is correct
12 Correct 8 ms 12892 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 4440 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 4444 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 4444 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 4568 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 0 ms 348 KB Output is correct
32 Correct 0 ms 344 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 0 ms 348 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 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 5 ms 1256 KB Output is correct
47 Correct 0 ms 1116 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 1116 KB Output is correct
50 Correct 1 ms 6748 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 40 ms 12764 KB Output is correct
6 Correct 2 ms 10840 KB Output is correct
7 Correct 2 ms 12888 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 2 ms 12892 KB Output is correct
11 Correct 2 ms 12892 KB Output is correct
12 Correct 8 ms 12892 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 4440 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 4444 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 4444 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 4568 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 0 ms 348 KB Output is correct
32 Correct 0 ms 344 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 0 ms 348 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 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 5 ms 1256 KB Output is correct
47 Correct 0 ms 1116 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 1116 KB Output is correct
50 Correct 1 ms 6748 KB Output is correct
51 Correct 4 ms 4444 KB Output is correct
52 Correct 2363 ms 12756 KB Output is correct
53 Correct 18 ms 12768 KB Output is correct
54 Correct 102 ms 12756 KB Output is correct
55 Correct 1 ms 4440 KB Output is correct
56 Correct 18 ms 6620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 33 ms 7012 KB Output is correct
3 Correct 33 ms 6996 KB Output is correct
4 Correct 26 ms 6992 KB Output is correct
5 Correct 38 ms 6992 KB Output is correct
6 Correct 28 ms 7004 KB Output is correct
7 Correct 39 ms 6992 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 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 33 ms 7012 KB Output is correct
3 Correct 33 ms 6996 KB Output is correct
4 Correct 26 ms 6992 KB Output is correct
5 Correct 38 ms 6992 KB Output is correct
6 Correct 28 ms 7004 KB Output is correct
7 Correct 39 ms 6992 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 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4568 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 147 ms 7120 KB Output is correct
21 Correct 125 ms 6992 KB Output is correct
22 Correct 118 ms 7128 KB Output is correct
23 Correct 110 ms 7504 KB Output is correct
24 Correct 354 ms 7112 KB Output is correct
25 Correct 161 ms 6996 KB Output is correct
26 Correct 161 ms 5316 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 2648 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 33 ms 7012 KB Output is correct
3 Correct 33 ms 6996 KB Output is correct
4 Correct 26 ms 6992 KB Output is correct
5 Correct 38 ms 6992 KB Output is correct
6 Correct 28 ms 7004 KB Output is correct
7 Correct 39 ms 6992 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 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4568 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 147 ms 7120 KB Output is correct
21 Correct 125 ms 6992 KB Output is correct
22 Correct 118 ms 7128 KB Output is correct
23 Correct 110 ms 7504 KB Output is correct
24 Correct 354 ms 7112 KB Output is correct
25 Correct 161 ms 6996 KB Output is correct
26 Correct 161 ms 5316 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 2648 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 211 ms 7120 KB Output is correct
48 Correct 200 ms 7120 KB Output is correct
49 Correct 242 ms 2108 KB Output is correct
50 Correct 157 ms 2388 KB Output is correct
51 Correct 3781 ms 4192 KB Output is correct
52 Correct 254 ms 7104 KB Output is correct
53 Correct 276 ms 7372 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 33 ms 7012 KB Output is correct
3 Correct 33 ms 6996 KB Output is correct
4 Correct 26 ms 6992 KB Output is correct
5 Correct 38 ms 6992 KB Output is correct
6 Correct 28 ms 7004 KB Output is correct
7 Correct 39 ms 6992 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 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4568 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 147 ms 7120 KB Output is correct
21 Correct 125 ms 6992 KB Output is correct
22 Correct 118 ms 7128 KB Output is correct
23 Correct 110 ms 7504 KB Output is correct
24 Correct 354 ms 7112 KB Output is correct
25 Correct 161 ms 6996 KB Output is correct
26 Correct 161 ms 5316 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 2648 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 211 ms 7120 KB Output is correct
48 Correct 200 ms 7120 KB Output is correct
49 Correct 242 ms 2108 KB Output is correct
50 Correct 157 ms 2388 KB Output is correct
51 Correct 3781 ms 4192 KB Output is correct
52 Correct 254 ms 7104 KB Output is correct
53 Correct 276 ms 7372 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 264 ms 9672 KB Output is correct
60 Correct 653 ms 7124 KB Output is correct
61 Correct 723 ms 6996 KB Output is correct
62 Correct 751 ms 5204 KB Output is correct
63 Correct 314 ms 2688 KB Output is correct
64 Correct 373 ms 4948 KB Output is correct
65 Correct 416 ms 6436 KB Output is correct
66 Correct 216 ms 4944 KB Output is correct
67 Execution timed out 4030 ms 3788 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 40 ms 12764 KB Output is correct
6 Correct 2 ms 10840 KB Output is correct
7 Correct 2 ms 12888 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 2 ms 12892 KB Output is correct
11 Correct 2 ms 12892 KB Output is correct
12 Correct 8 ms 12892 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 4440 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 4444 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 4444 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 4568 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 0 ms 348 KB Output is correct
32 Correct 0 ms 344 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 0 ms 348 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 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 5 ms 1256 KB Output is correct
47 Correct 0 ms 1116 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 1116 KB Output is correct
50 Correct 1 ms 6748 KB Output is correct
51 Correct 4 ms 4444 KB Output is correct
52 Correct 2363 ms 12756 KB Output is correct
53 Correct 18 ms 12768 KB Output is correct
54 Correct 102 ms 12756 KB Output is correct
55 Correct 1 ms 4440 KB Output is correct
56 Correct 18 ms 6620 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 33 ms 7012 KB Output is correct
59 Correct 33 ms 6996 KB Output is correct
60 Correct 26 ms 6992 KB Output is correct
61 Correct 38 ms 6992 KB Output is correct
62 Correct 28 ms 7004 KB Output is correct
63 Correct 39 ms 6992 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 4440 KB Output is correct
71 Correct 1 ms 4440 KB Output is correct
72 Correct 1 ms 4444 KB Output is correct
73 Correct 1 ms 4568 KB Output is correct
74 Correct 1 ms 4444 KB Output is correct
75 Correct 1 ms 4444 KB Output is correct
76 Correct 147 ms 7120 KB Output is correct
77 Correct 125 ms 6992 KB Output is correct
78 Correct 118 ms 7128 KB Output is correct
79 Correct 110 ms 7504 KB Output is correct
80 Correct 354 ms 7112 KB Output is correct
81 Correct 161 ms 6996 KB Output is correct
82 Correct 161 ms 5316 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 1 ms 348 KB Output is correct
85 Correct 1 ms 348 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 1 ms 348 KB Output is correct
88 Correct 1 ms 2396 KB Output is correct
89 Correct 1 ms 344 KB Output is correct
90 Correct 1 ms 2392 KB Output is correct
91 Correct 0 ms 348 KB Output is correct
92 Correct 1 ms 348 KB Output is correct
93 Correct 1 ms 2396 KB Output is correct
94 Correct 0 ms 344 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 0 ms 348 KB Output is correct
97 Correct 1 ms 2648 KB Output is correct
98 Correct 0 ms 348 KB Output is correct
99 Correct 1 ms 2396 KB Output is correct
100 Correct 1 ms 4444 KB Output is correct
101 Correct 1 ms 2396 KB Output is correct
102 Correct 0 ms 344 KB Output is correct
103 Correct 211 ms 7120 KB Output is correct
104 Correct 200 ms 7120 KB Output is correct
105 Correct 242 ms 2108 KB Output is correct
106 Correct 157 ms 2388 KB Output is correct
107 Correct 3781 ms 4192 KB Output is correct
108 Correct 254 ms 7104 KB Output is correct
109 Correct 276 ms 7372 KB Output is correct
110 Correct 1 ms 4444 KB Output is correct
111 Correct 1 ms 4444 KB Output is correct
112 Correct 1 ms 4444 KB Output is correct
113 Correct 1 ms 4444 KB Output is correct
114 Correct 1 ms 604 KB Output is correct
115 Correct 264 ms 9672 KB Output is correct
116 Correct 653 ms 7124 KB Output is correct
117 Correct 723 ms 6996 KB Output is correct
118 Correct 751 ms 5204 KB Output is correct
119 Correct 314 ms 2688 KB Output is correct
120 Correct 373 ms 4948 KB Output is correct
121 Correct 416 ms 6436 KB Output is correct
122 Correct 216 ms 4944 KB Output is correct
123 Execution timed out 4030 ms 3788 KB Time limit exceeded
124 Halted 0 ms 0 KB -