답안 #783836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783836 2023-07-15T11:19:30 Z YassineBenYounes Council (JOI23_council) C++17
41 / 100
4000 ms 10164 KB
#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pbds tree<pair<ll, ll>, null_type, less<pair<ll,ll>>,rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
////////////////////Only Clear Code//////////////////////////
void usaco_problem(){
    freopen("milkvisits.in", "r", stdin);
    freopen("milkvisits.out", "w", stdout);
}

void init(){
    #ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output.txt", "w", stdout);
 
#endif // ONLINE_JUDGE
}

const int mx = (1 << 20)+5;
const int LOG = 25;
const ll inf = 1e18;
const ll mod = 1e8;

int arr[mx];

int sum[25];

int freq[mx], cnt[mx];

void run_case(){
    int n, m;cin >> n >> m; 
    for(int i = 0; i < n;i++){
        for(int j = 0;j < m;j++){
            int a;cin >> a;
            arr[i] += (1 << j) * a;
            sum[j] += a;
        }
        freq[arr[i]]++;
    }
    for(int i = 0; i < (1 << m);i++){
        for(int j = 0;j < m;j++){
            if((1 << j) & i){
                cnt[i]++;
            }
        }
    }
    for(int i = 0; i < n;i++){
        int res = 0, ans = 0;
        int x = 0;
        for(int j = 0;j < m;j++){
            bool p =(arr[i] & (1 << j));
            sum[j] -= p;
            if(sum[j] == n/2)x += (1 << j);
            if(sum[j] >= n/2)res++;
        }
        //cout << res << endl;
        for(int mask = 0; mask < (1 << m);mask++){
            int k = x & mask;
            int target = cnt[k];
            //cout << mask << " " << target << endl;
            if(mask == arr[i]){
                if(freq[mask] >= 2){
                    ans = max(ans, res-target);
                }
            }
            else if(freq[mask] >= 1){
                ans = max(ans, res-target);
            }
        }
        cout << ans << endl;
        for(int j = 0;j < m;j++){
            bool p =(arr[i] & (1 << j));
            sum[j] += p;
        }
    }
}

int32_t main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--){
        run_case();
    }
}

/*
    NEVER GIVE UP!
    DOING SMTHNG IS BETTER THAN DOING NTHNG!!!
    Your Guide when stuck:
    - Continue keyword only after reading the whole input
    - Don't use memset with testcases
    - Check for corner cases(n=1, n=0)
    - Check where you declare n(Be careful of declaring it globally and in main)
*/

Compilation message

council.cpp: In function 'void usaco_problem()':
council.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("milkvisits.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
council.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("milkvisits.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
council.cpp: In function 'void init()':
council.cpp:18:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
council.cpp:20:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 102 ms 4384 KB Output is correct
6 Correct 363 ms 4408 KB Output is correct
7 Correct 70 ms 4432 KB Output is correct
8 Correct 86 ms 4408 KB Output is correct
9 Correct 361 ms 5480 KB Output is correct
10 Correct 70 ms 4428 KB Output is correct
11 Correct 85 ms 4436 KB Output is correct
12 Correct 363 ms 5452 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 328 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 12 ms 880 KB Output is correct
47 Correct 9 ms 852 KB Output is correct
48 Correct 10 ms 852 KB Output is correct
49 Correct 10 ms 832 KB Output is correct
50 Correct 11 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 102 ms 4384 KB Output is correct
6 Correct 363 ms 4408 KB Output is correct
7 Correct 70 ms 4432 KB Output is correct
8 Correct 86 ms 4408 KB Output is correct
9 Correct 361 ms 5480 KB Output is correct
10 Correct 70 ms 4428 KB Output is correct
11 Correct 85 ms 4436 KB Output is correct
12 Correct 363 ms 5452 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 328 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 12 ms 880 KB Output is correct
47 Correct 9 ms 852 KB Output is correct
48 Correct 10 ms 852 KB Output is correct
49 Correct 10 ms 832 KB Output is correct
50 Correct 11 ms 852 KB Output is correct
51 Correct 3174 ms 4708 KB Output is correct
52 Correct 3066 ms 4564 KB Output is correct
53 Correct 3331 ms 8480 KB Output is correct
54 Correct 3112 ms 8468 KB Output is correct
55 Correct 4 ms 336 KB Output is correct
56 Correct 458 ms 1472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 328 ms 2092 KB Output is correct
3 Correct 325 ms 2284 KB Output is correct
4 Correct 301 ms 2236 KB Output is correct
5 Correct 329 ms 2260 KB Output is correct
6 Correct 305 ms 2136 KB Output is correct
7 Correct 319 ms 3256 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 328 ms 2092 KB Output is correct
3 Correct 325 ms 2284 KB Output is correct
4 Correct 301 ms 2236 KB Output is correct
5 Correct 329 ms 2260 KB Output is correct
6 Correct 305 ms 2136 KB Output is correct
7 Correct 319 ms 3256 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 797 ms 7888 KB Output is correct
21 Correct 632 ms 7272 KB Output is correct
22 Correct 607 ms 7252 KB Output is correct
23 Correct 711 ms 8196 KB Output is correct
24 Correct 760 ms 7940 KB Output is correct
25 Correct 757 ms 7964 KB Output is correct
26 Correct 762 ms 7968 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 328 ms 2092 KB Output is correct
3 Correct 325 ms 2284 KB Output is correct
4 Correct 301 ms 2236 KB Output is correct
5 Correct 329 ms 2260 KB Output is correct
6 Correct 305 ms 2136 KB Output is correct
7 Correct 319 ms 3256 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 797 ms 7888 KB Output is correct
21 Correct 632 ms 7272 KB Output is correct
22 Correct 607 ms 7252 KB Output is correct
23 Correct 711 ms 8196 KB Output is correct
24 Correct 760 ms 7940 KB Output is correct
25 Correct 757 ms 7964 KB Output is correct
26 Correct 762 ms 7968 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Execution timed out 4073 ms 10164 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 328 ms 2092 KB Output is correct
3 Correct 325 ms 2284 KB Output is correct
4 Correct 301 ms 2236 KB Output is correct
5 Correct 329 ms 2260 KB Output is correct
6 Correct 305 ms 2136 KB Output is correct
7 Correct 319 ms 3256 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 797 ms 7888 KB Output is correct
21 Correct 632 ms 7272 KB Output is correct
22 Correct 607 ms 7252 KB Output is correct
23 Correct 711 ms 8196 KB Output is correct
24 Correct 760 ms 7940 KB Output is correct
25 Correct 757 ms 7964 KB Output is correct
26 Correct 762 ms 7968 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Execution timed out 4073 ms 10164 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 102 ms 4384 KB Output is correct
6 Correct 363 ms 4408 KB Output is correct
7 Correct 70 ms 4432 KB Output is correct
8 Correct 86 ms 4408 KB Output is correct
9 Correct 361 ms 5480 KB Output is correct
10 Correct 70 ms 4428 KB Output is correct
11 Correct 85 ms 4436 KB Output is correct
12 Correct 363 ms 5452 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 328 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 12 ms 880 KB Output is correct
47 Correct 9 ms 852 KB Output is correct
48 Correct 10 ms 852 KB Output is correct
49 Correct 10 ms 832 KB Output is correct
50 Correct 11 ms 852 KB Output is correct
51 Correct 3174 ms 4708 KB Output is correct
52 Correct 3066 ms 4564 KB Output is correct
53 Correct 3331 ms 8480 KB Output is correct
54 Correct 3112 ms 8468 KB Output is correct
55 Correct 4 ms 336 KB Output is correct
56 Correct 458 ms 1472 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 328 ms 2092 KB Output is correct
59 Correct 325 ms 2284 KB Output is correct
60 Correct 301 ms 2236 KB Output is correct
61 Correct 329 ms 2260 KB Output is correct
62 Correct 305 ms 2136 KB Output is correct
63 Correct 319 ms 3256 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 328 KB Output is correct
68 Correct 1 ms 324 KB Output is correct
69 Correct 0 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 328 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 4 ms 340 KB Output is correct
74 Correct 1 ms 328 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 797 ms 7888 KB Output is correct
77 Correct 632 ms 7272 KB Output is correct
78 Correct 607 ms 7252 KB Output is correct
79 Correct 711 ms 8196 KB Output is correct
80 Correct 760 ms 7940 KB Output is correct
81 Correct 757 ms 7964 KB Output is correct
82 Correct 762 ms 7968 KB Output is correct
83 Correct 1 ms 340 KB Output is correct
84 Correct 1 ms 340 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 1 ms 328 KB Output is correct
87 Correct 1 ms 340 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 1 ms 340 KB Output is correct
92 Correct 2 ms 340 KB Output is correct
93 Correct 1 ms 340 KB Output is correct
94 Correct 0 ms 340 KB Output is correct
95 Correct 1 ms 340 KB Output is correct
96 Correct 1 ms 340 KB Output is correct
97 Correct 1 ms 324 KB Output is correct
98 Correct 1 ms 340 KB Output is correct
99 Correct 1 ms 340 KB Output is correct
100 Correct 1 ms 340 KB Output is correct
101 Correct 1 ms 340 KB Output is correct
102 Correct 1 ms 340 KB Output is correct
103 Execution timed out 4073 ms 10164 KB Time limit exceeded
104 Halted 0 ms 0 KB -