답안 #1109475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109475 2024-11-06T19:51:07 Z vladilius Council (JOI23_council) C++17
33 / 100
4000 ms 87212 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, m; cin>>n>>m;
    vector<vector<bool>> a(n + 1, vector<bool>(m + 1));
    vector<int> A[m + 1], B[n + 1];
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            bool b; cin>>b;
            if (b){
                A[j].pb(i);
                B[i].pb(j);
            }
            a[i][j] = b;
        }
    }
    
    vector<int> x(m + 1);
    for (int i = 1; i <= m; i++) x[i] = (int) A[i].size();
    
    vector<int> tw(m + 1); tw[0] = 1;
    for (int i = 1; i <= m; i++){
        tw[i] = tw[i - 1] * 2;
    }
    vector<int> y(n + 1), out(n + 1), p1(n + 1), p2(n + 2), d[tw[m]];
    
    const int M = n / 2;
    vector<int> all;
    
    for (int i = 1; i <= n; i++){
        for (int j: B[i]) x[j]--;
        
        all.clear();
        int f = m;
        for (int j = 1; j <= m; j++){
            if (x[j] != M){
                f -= (x[j] < M);
                continue;
            }
            all.pb(j);
        }
        
        int v = 0;
        for (int j: all){
            v += tw[j - 1];
        }
        
        d[v].pb(i);
        out[i] = f;

        for (int j: B[i]) x[j]++;
    }
    
    function<void(int, int)> rec = [&](int i, int v){
        if (i == m + 1){
            p1[0] = 1e9;
            for (int j = 1; j <= n; j++){
                p1[j] = min(p1[j - 1], y[j]);
            }
            p2[n + 1] = 1e9;
            for (int j = n; j > 0; j--){
                p2[j] = min(p2[j + 1], y[j]);
            }
            
            for (int k: d[v]){
                out[k] -= min(p1[k - 1], p2[k + 1]);
            }
            return;
        }
        rec(i + 1, v);
        for (int j: A[i]){
            y[j]++;
        }
        rec(i + 1, v + tw[i - 1]);
        for (int j: A[i]){
            y[j]--;
        }
    };
    rec(1, 0);
    
    for (int i = 1; i <= n; i++){
        cout<<out[i]<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 247 ms 25072 KB Output is correct
6 Correct 1045 ms 25216 KB Output is correct
7 Correct 110 ms 24912 KB Output is correct
8 Correct 187 ms 24960 KB Output is correct
9 Correct 839 ms 25160 KB Output is correct
10 Correct 116 ms 24904 KB Output is correct
11 Correct 198 ms 24924 KB Output is correct
12 Correct 870 ms 25180 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 3 ms 336 KB Output is correct
41 Correct 2 ms 720 KB Output is correct
42 Correct 1 ms 592 KB Output is correct
43 Correct 2 ms 1016 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 848 KB Output is correct
46 Correct 16 ms 3544 KB Output is correct
47 Correct 7 ms 3408 KB Output is correct
48 Correct 11 ms 3420 KB Output is correct
49 Correct 7 ms 3408 KB Output is correct
50 Correct 13 ms 3520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 247 ms 25072 KB Output is correct
6 Correct 1045 ms 25216 KB Output is correct
7 Correct 110 ms 24912 KB Output is correct
8 Correct 187 ms 24960 KB Output is correct
9 Correct 839 ms 25160 KB Output is correct
10 Correct 116 ms 24904 KB Output is correct
11 Correct 198 ms 24924 KB Output is correct
12 Correct 870 ms 25180 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 3 ms 336 KB Output is correct
41 Correct 2 ms 720 KB Output is correct
42 Correct 1 ms 592 KB Output is correct
43 Correct 2 ms 1016 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 848 KB Output is correct
46 Correct 16 ms 3544 KB Output is correct
47 Correct 7 ms 3408 KB Output is correct
48 Correct 11 ms 3420 KB Output is correct
49 Correct 7 ms 3408 KB Output is correct
50 Correct 13 ms 3520 KB Output is correct
51 Execution timed out 4054 ms 26192 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 111 ms 51480 KB Output is correct
3 Correct 69 ms 36436 KB Output is correct
4 Correct 70 ms 41716 KB Output is correct
5 Correct 92 ms 44724 KB Output is correct
6 Correct 73 ms 41012 KB Output is correct
7 Correct 92 ms 44080 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 111 ms 51480 KB Output is correct
3 Correct 69 ms 36436 KB Output is correct
4 Correct 70 ms 41716 KB Output is correct
5 Correct 92 ms 44724 KB Output is correct
6 Correct 73 ms 41012 KB Output is correct
7 Correct 92 ms 44080 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 848 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 882 ms 62032 KB Output is correct
21 Correct 550 ms 58600 KB Output is correct
22 Correct 538 ms 58284 KB Output is correct
23 Correct 3035 ms 87212 KB Output is correct
24 Correct 642 ms 42176 KB Output is correct
25 Correct 887 ms 60512 KB Output is correct
26 Correct 935 ms 60336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 504 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 111 ms 51480 KB Output is correct
3 Correct 69 ms 36436 KB Output is correct
4 Correct 70 ms 41716 KB Output is correct
5 Correct 92 ms 44724 KB Output is correct
6 Correct 73 ms 41012 KB Output is correct
7 Correct 92 ms 44080 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 848 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 882 ms 62032 KB Output is correct
21 Correct 550 ms 58600 KB Output is correct
22 Correct 538 ms 58284 KB Output is correct
23 Correct 3035 ms 87212 KB Output is correct
24 Correct 642 ms 42176 KB Output is correct
25 Correct 887 ms 60512 KB Output is correct
26 Correct 935 ms 60336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 504 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 2 ms 336 KB Output is correct
46 Correct 2 ms 456 KB Output is correct
47 Execution timed out 4091 ms 66060 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 111 ms 51480 KB Output is correct
3 Correct 69 ms 36436 KB Output is correct
4 Correct 70 ms 41716 KB Output is correct
5 Correct 92 ms 44724 KB Output is correct
6 Correct 73 ms 41012 KB Output is correct
7 Correct 92 ms 44080 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 848 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 882 ms 62032 KB Output is correct
21 Correct 550 ms 58600 KB Output is correct
22 Correct 538 ms 58284 KB Output is correct
23 Correct 3035 ms 87212 KB Output is correct
24 Correct 642 ms 42176 KB Output is correct
25 Correct 887 ms 60512 KB Output is correct
26 Correct 935 ms 60336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 504 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 2 ms 336 KB Output is correct
46 Correct 2 ms 456 KB Output is correct
47 Execution timed out 4091 ms 66060 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 247 ms 25072 KB Output is correct
6 Correct 1045 ms 25216 KB Output is correct
7 Correct 110 ms 24912 KB Output is correct
8 Correct 187 ms 24960 KB Output is correct
9 Correct 839 ms 25160 KB Output is correct
10 Correct 116 ms 24904 KB Output is correct
11 Correct 198 ms 24924 KB Output is correct
12 Correct 870 ms 25180 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 3 ms 336 KB Output is correct
41 Correct 2 ms 720 KB Output is correct
42 Correct 1 ms 592 KB Output is correct
43 Correct 2 ms 1016 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 848 KB Output is correct
46 Correct 16 ms 3544 KB Output is correct
47 Correct 7 ms 3408 KB Output is correct
48 Correct 11 ms 3420 KB Output is correct
49 Correct 7 ms 3408 KB Output is correct
50 Correct 13 ms 3520 KB Output is correct
51 Execution timed out 4054 ms 26192 KB Time limit exceeded
52 Halted 0 ms 0 KB -