답안 #1077666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077666 2024-08-27T08:32:14 Z vjudge1 Council (JOI23_council) C++
56 / 100
4000 ms 19244 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;
      |               ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4564 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 40 ms 12892 KB Output is correct
6 Correct 3 ms 4444 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12952 KB Output is correct
9 Correct 5 ms 12124 KB Output is correct
10 Correct 5 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 10 ms 12124 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 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 2396 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 2 ms 4444 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 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 6 ms 4956 KB Output is correct
47 Correct 1 ms 6748 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 6612 KB Output is correct
50 Correct 2 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4564 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 40 ms 12892 KB Output is correct
6 Correct 3 ms 4444 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12952 KB Output is correct
9 Correct 5 ms 12124 KB Output is correct
10 Correct 5 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 10 ms 12124 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 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 2396 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 2 ms 4444 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 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 6 ms 4956 KB Output is correct
47 Correct 1 ms 6748 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 6612 KB Output is correct
50 Correct 2 ms 6748 KB Output is correct
51 Correct 5 ms 8700 KB Output is correct
52 Correct 2344 ms 12116 KB Output is correct
53 Correct 21 ms 12120 KB Output is correct
54 Correct 65 ms 12888 KB Output is correct
55 Correct 2 ms 4440 KB Output is correct
56 Correct 19 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 37 ms 8236 KB Output is correct
3 Correct 35 ms 8144 KB Output is correct
4 Correct 27 ms 7760 KB Output is correct
5 Correct 37 ms 8176 KB Output is correct
6 Correct 27 ms 7620 KB Output is correct
7 Correct 41 ms 8276 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 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4568 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 37 ms 8236 KB Output is correct
3 Correct 35 ms 8144 KB Output is correct
4 Correct 27 ms 7760 KB Output is correct
5 Correct 37 ms 8176 KB Output is correct
6 Correct 27 ms 7620 KB Output is correct
7 Correct 41 ms 8276 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 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4568 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 140 ms 10140 KB Output is correct
21 Correct 134 ms 9340 KB Output is correct
22 Correct 127 ms 9552 KB Output is correct
23 Correct 135 ms 10324 KB Output is correct
24 Correct 343 ms 10048 KB Output is correct
25 Correct 161 ms 12888 KB Output is correct
26 Correct 168 ms 12884 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 4568 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 348 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 4440 KB Output is correct
37 Correct 1 ms 4440 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4440 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 37 ms 8236 KB Output is correct
3 Correct 35 ms 8144 KB Output is correct
4 Correct 27 ms 7760 KB Output is correct
5 Correct 37 ms 8176 KB Output is correct
6 Correct 27 ms 7620 KB Output is correct
7 Correct 41 ms 8276 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 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4568 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 140 ms 10140 KB Output is correct
21 Correct 134 ms 9340 KB Output is correct
22 Correct 127 ms 9552 KB Output is correct
23 Correct 135 ms 10324 KB Output is correct
24 Correct 343 ms 10048 KB Output is correct
25 Correct 161 ms 12888 KB Output is correct
26 Correct 168 ms 12884 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 4568 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 348 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 4440 KB Output is correct
37 Correct 1 ms 4440 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4440 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 432 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 209 ms 10324 KB Output is correct
48 Correct 236 ms 9792 KB Output is correct
49 Correct 199 ms 12916 KB Output is correct
50 Correct 182 ms 13908 KB Output is correct
51 Correct 3727 ms 13504 KB Output is correct
52 Correct 243 ms 12368 KB Output is correct
53 Correct 278 ms 15684 KB Output is correct
54 Correct 1 ms 4440 KB Output is correct
55 Correct 1 ms 4564 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 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 37 ms 8236 KB Output is correct
3 Correct 35 ms 8144 KB Output is correct
4 Correct 27 ms 7760 KB Output is correct
5 Correct 37 ms 8176 KB Output is correct
6 Correct 27 ms 7620 KB Output is correct
7 Correct 41 ms 8276 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 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4568 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 140 ms 10140 KB Output is correct
21 Correct 134 ms 9340 KB Output is correct
22 Correct 127 ms 9552 KB Output is correct
23 Correct 135 ms 10324 KB Output is correct
24 Correct 343 ms 10048 KB Output is correct
25 Correct 161 ms 12888 KB Output is correct
26 Correct 168 ms 12884 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 4568 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 348 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 4440 KB Output is correct
37 Correct 1 ms 4440 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4440 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 432 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 209 ms 10324 KB Output is correct
48 Correct 236 ms 9792 KB Output is correct
49 Correct 199 ms 12916 KB Output is correct
50 Correct 182 ms 13908 KB Output is correct
51 Correct 3727 ms 13504 KB Output is correct
52 Correct 243 ms 12368 KB Output is correct
53 Correct 278 ms 15684 KB Output is correct
54 Correct 1 ms 4440 KB Output is correct
55 Correct 1 ms 4564 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 4444 KB Output is correct
59 Correct 231 ms 18788 KB Output is correct
60 Correct 601 ms 10832 KB Output is correct
61 Correct 663 ms 11100 KB Output is correct
62 Correct 696 ms 11344 KB Output is correct
63 Correct 277 ms 18512 KB Output is correct
64 Correct 370 ms 19024 KB Output is correct
65 Correct 355 ms 19144 KB Output is correct
66 Correct 228 ms 19244 KB Output is correct
67 Execution timed out 4078 ms 16212 KB Time limit exceeded
68 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4564 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 40 ms 12892 KB Output is correct
6 Correct 3 ms 4444 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12952 KB Output is correct
9 Correct 5 ms 12124 KB Output is correct
10 Correct 5 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 10 ms 12124 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 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 2396 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 2 ms 4444 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 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 6 ms 4956 KB Output is correct
47 Correct 1 ms 6748 KB Output is correct
48 Correct 1 ms 6748 KB Output is correct
49 Correct 1 ms 6612 KB Output is correct
50 Correct 2 ms 6748 KB Output is correct
51 Correct 5 ms 8700 KB Output is correct
52 Correct 2344 ms 12116 KB Output is correct
53 Correct 21 ms 12120 KB Output is correct
54 Correct 65 ms 12888 KB Output is correct
55 Correct 2 ms 4440 KB Output is correct
56 Correct 19 ms 6744 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 37 ms 8236 KB Output is correct
59 Correct 35 ms 8144 KB Output is correct
60 Correct 27 ms 7760 KB Output is correct
61 Correct 37 ms 8176 KB Output is correct
62 Correct 27 ms 7620 KB Output is correct
63 Correct 41 ms 8276 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 2396 KB Output is correct
70 Correct 1 ms 4444 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 4568 KB Output is correct
73 Correct 1 ms 4444 KB Output is correct
74 Correct 1 ms 4444 KB Output is correct
75 Correct 1 ms 4444 KB Output is correct
76 Correct 140 ms 10140 KB Output is correct
77 Correct 134 ms 9340 KB Output is correct
78 Correct 127 ms 9552 KB Output is correct
79 Correct 135 ms 10324 KB Output is correct
80 Correct 343 ms 10048 KB Output is correct
81 Correct 161 ms 12888 KB Output is correct
82 Correct 168 ms 12884 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 4568 KB Output is correct
87 Correct 1 ms 4444 KB Output is correct
88 Correct 1 ms 4444 KB Output is correct
89 Correct 1 ms 348 KB Output is correct
90 Correct 1 ms 4444 KB Output is correct
91 Correct 1 ms 348 KB Output is correct
92 Correct 1 ms 4440 KB Output is correct
93 Correct 1 ms 4440 KB Output is correct
94 Correct 1 ms 4440 KB Output is correct
95 Correct 1 ms 4440 KB Output is correct
96 Correct 1 ms 2396 KB Output is correct
97 Correct 1 ms 2396 KB Output is correct
98 Correct 1 ms 2396 KB Output is correct
99 Correct 1 ms 348 KB Output is correct
100 Correct 1 ms 348 KB Output is correct
101 Correct 0 ms 432 KB Output is correct
102 Correct 1 ms 4444 KB Output is correct
103 Correct 209 ms 10324 KB Output is correct
104 Correct 236 ms 9792 KB Output is correct
105 Correct 199 ms 12916 KB Output is correct
106 Correct 182 ms 13908 KB Output is correct
107 Correct 3727 ms 13504 KB Output is correct
108 Correct 243 ms 12368 KB Output is correct
109 Correct 278 ms 15684 KB Output is correct
110 Correct 1 ms 4440 KB Output is correct
111 Correct 1 ms 4564 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 4444 KB Output is correct
115 Correct 231 ms 18788 KB Output is correct
116 Correct 601 ms 10832 KB Output is correct
117 Correct 663 ms 11100 KB Output is correct
118 Correct 696 ms 11344 KB Output is correct
119 Correct 277 ms 18512 KB Output is correct
120 Correct 370 ms 19024 KB Output is correct
121 Correct 355 ms 19144 KB Output is correct
122 Correct 228 ms 19244 KB Output is correct
123 Execution timed out 4078 ms 16212 KB Time limit exceeded
124 Halted 0 ms 0 KB -