Submission #978603

# Submission time Handle Problem Language Result Execution time Memory
978603 2024-05-09T11:16:24 Z vjudge1 Council (JOI23_council) C++17
22 / 100
4000 ms 30972 KB
#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

int tt = 1, n, m;
int A[300001][21], cnt[22];
map<vector<int>, int> mp;
int f[10];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        vector<int> v;
        for(int j = 1; j <= m; j++){
            cin >> A[i][j];
            cnt[j] += A[i][j];
            v.push_back(A[i][j]);
        }
       if(m == 2) mp[v]++;
    }
    vector<int> v1, v2, v3, v4;
    v1 = {0, 0};
    v2 = {1, 0};
    v3 = {0, 1};
    v4 = {1, 1};
    f[0] = mp[v1];
    f[1] = mp[v2];
    f[2] = mp[v3];
    f[3] = mp[v4];
    for(int i = 1; i <= n; i++){
        int mx = 0;
        if(m == 1){
            if(cnt[1] - A[i][1] >= n / 2) cout << 1 << "\n";
            else cout << 0 << "\n";
            continue;
        }
        if(m == 2){
            vector<int> vv;
            for(int j = 1; j <= m; j++) vv.push_back(A[i][j]);
            int ind = 0;
            if(vv == v1){
                f[0]--;
                ind = 0;
            }
            if(vv == v2){
                f[1]--;
                ind = 1;
            }
            if(vv == v3){
                f[2]--;
                ind = 2;
            }
            if(vv == v4){
                f[3]--;
                ind = 3;
            }
            int f1 = 0, f2 = 0, kol = 2;
            if(cnt[1] - A[i][1] == n / 2) f1 = 1;
            if(cnt[1] - A[i][1] < n / 2) f1 = 2;

            if(cnt[2] - A[i][2] == n / 2) f2 = 1;
            if(cnt[2] - A[i][2] < n / 2) f2 = 2;

            if(f1 == 0 && f2 == 0){
                cout << 2 << "\n";
                f[ind]++;
                continue;
            }
            if(f1 == 2) kol--;
            if(f2 == 2) kol--;
            if(f[0] > 0){
                cout << kol << "\n";
                f[ind]++;
                continue;
            }
            if(kol == 0){
                cout << kol << "\n";
                f[ind]++;
                continue;
            }
            if(f1 == 1 && f[2] > 0){
                if(f2 == 1) kol--;
                cout << kol << "\n";
                f[ind]++;
                continue;
            }
            if(f2 == 1 && f[1] > 0){
                if(f1 == 1) kol--;
                cout << kol << "\n";
                f[ind]++;
                continue;
            }
            // cout << i << " " << f1 << " " << f2 << " " << kol << "\n";
            if(f1 == 1) kol--;
            if(f2 == 1) kol--;
            cout << kol << "\n";
            f[ind]++;
            continue;
        }
        for(int j = 1; j <= n; j++){
            if(i == j) continue;
            int kol = 0;
            for(int ind = 1; ind <= m; ind++){
                if(cnt[ind] - A[i][ind] - A[j][ind] >= n / 2) 
                    kol++;
            }
            mx = max(mx, kol);
        }
        cout << mx << "\n";
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 0 ms 376 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 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 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 0 ms 376 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 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 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 214 ms 2652 KB Output is correct
52 Correct 205 ms 2648 KB Output is correct
53 Correct 215 ms 2668 KB Output is correct
54 Correct 202 ms 2676 KB Output is correct
55 Correct 2 ms 2652 KB Output is correct
56 Correct 228 ms 2660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 96 ms 25692 KB Output is correct
3 Correct 95 ms 25484 KB Output is correct
4 Correct 40 ms 25692 KB Output is correct
5 Correct 103 ms 26704 KB Output is correct
6 Correct 42 ms 26104 KB Output is correct
7 Correct 94 ms 26624 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 464 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 372 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 96 ms 25692 KB Output is correct
3 Correct 95 ms 25484 KB Output is correct
4 Correct 40 ms 25692 KB Output is correct
5 Correct 103 ms 26704 KB Output is correct
6 Correct 42 ms 26104 KB Output is correct
7 Correct 94 ms 26624 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 464 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 372 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Execution timed out 4027 ms 30972 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 96 ms 25692 KB Output is correct
3 Correct 95 ms 25484 KB Output is correct
4 Correct 40 ms 25692 KB Output is correct
5 Correct 103 ms 26704 KB Output is correct
6 Correct 42 ms 26104 KB Output is correct
7 Correct 94 ms 26624 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 464 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 372 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Execution timed out 4027 ms 30972 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 96 ms 25692 KB Output is correct
3 Correct 95 ms 25484 KB Output is correct
4 Correct 40 ms 25692 KB Output is correct
5 Correct 103 ms 26704 KB Output is correct
6 Correct 42 ms 26104 KB Output is correct
7 Correct 94 ms 26624 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 464 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 372 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Execution timed out 4027 ms 30972 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 0 ms 376 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 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 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 214 ms 2652 KB Output is correct
52 Correct 205 ms 2648 KB Output is correct
53 Correct 215 ms 2668 KB Output is correct
54 Correct 202 ms 2676 KB Output is correct
55 Correct 2 ms 2652 KB Output is correct
56 Correct 228 ms 2660 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 96 ms 25692 KB Output is correct
59 Correct 95 ms 25484 KB Output is correct
60 Correct 40 ms 25692 KB Output is correct
61 Correct 103 ms 26704 KB Output is correct
62 Correct 42 ms 26104 KB Output is correct
63 Correct 94 ms 26624 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 1 ms 468 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 1 ms 464 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 1 ms 372 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 2 ms 2652 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Execution timed out 4027 ms 30972 KB Time limit exceeded
77 Halted 0 ms 0 KB -