답안 #889124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889124 2023-12-19T01:00:33 Z thunopro Council (JOI23_council) C++14
41 / 100
201 ms 37196 KB
#include<bits/stdc++.h>
using namespace std ;
#define maxn 200009 
#define ll long long
#define fi first 
#define se second 
#define pb push_back 
#define left id<<1
#define right id<<1|1 
#define re exit(0); 

const int mod = 1e9+7 ; 
const int INF = 1e9 ; 
const int LOG = 18 ; 

typedef vector<int> vi ; 
typedef vector<ll> vl ; 
typedef pair<int,int> pii ; 
typedef vector<pii> vii ; 
typedef pair<ll,ll> pll ;  

void add ( int &a , int b ) 
{
	a += b ; 
	if ( a < 0 ) a += mod ; 
	if ( a >= mod ) a -= mod ; 
}

template < typename T > void chkmin (T &a , T b) { if (a>b) a=b ;} 
template < typename T > void chkmax (T &a , T b) { if (a<b) a=b ;}

void rf () 
{
	freopen ("bai1.inp","r",stdin) ; 
//	freopen ("bai1.out","w",stdout) ; 
}

const int N = 1<<20 ; 
int n , m ; 
int a [N][22] ; 
int ans [N] ; 
int scol [22] ; 

void sub1 () 
{
	for ( int i = 1 ; i <= n ; i ++ ) 
	{
		for ( int j = i + 1 ; j <= n ; j ++ ) 
		{
			int num = 0 ; 
			for ( int t = 1 ; t <= m ; t ++ ) 
			{
				int cnt = scol [t] - a [i][t] - a [j][t] ;
				if ( cnt >= n/2 ) num ++ ; 
			}
			chkmax (ans[i],num) ; 
			chkmax (ans[j],num) ; 
		}
	}
	for ( int i = 1 ; i <= n ; i ++ ) cout << ans [i] << "\n" ; 
}

int used [N] ; 
void sub2 () 
{
	for ( int i = 1 ; i <= n ; i ++ ) 
	{
		int mask = 0 ; 
		for ( int j = 0 ; j < m ; j ++ ) mask += a[i][j+1]*(1<<j) ; 
		used [mask] ++ ; 
	}

	for ( int mask = 0 ; mask < (1<<m) ; mask ++ ) 
	{
		for ( int _mask = 0 ; _mask < (1<<m) ; _mask ++ ) 
		{
			if ( ! used [mask] || ! used [_mask] ) continue ; 
			if ( mask == _mask && used [mask] < 2 ) continue ; 
			int num = 0 ; 
			for ( int i = 0 ; i < m ; i ++ ) 
			{
				int cnt = scol [i+1] - (mask>>i&1) - (_mask>>i&1) ; 
				if ( cnt >= n/2 ) num ++ ; 
			}
			chkmax (ans[mask],num) ; 
			chkmax (ans[_mask],num) ; 
		}
	}
	for ( int i = 1 ; i <= n ; i ++ ) 
	{
		int mask = 0 ; 
		for ( int j = 0 ; j < m ; j ++ ) mask += a[i][j+1]*(1<<j) ; 
		cout << ans [mask] << "\n" ; 
	}
}
int main () 
{
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; cout.tie(0) ; 
//	rf () ; 
	cin >> n >> m ; 
	for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= m ; j ++ ) cin >> a [i][j] ; 
	
	for ( int j = 1 ; j <= m ; j ++ ) for ( int i = 1 ; i <= n ; i ++ ) scol [j] += a [i][j] ; 

	if ( n <= 3000 ) sub1 () ; 
	else if ( m <= 10 ) sub2 () ; 
}

Compilation message

council.cpp: In function 'void rf()':
council.cpp:34:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  freopen ("bai1.inp","r",stdin) ;
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2460 KB Output is correct
39 Correct 0 ms 2396 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 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2460 KB Output is correct
39 Correct 0 ms 2396 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 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 76 ms 4444 KB Output is correct
52 Correct 81 ms 4696 KB Output is correct
53 Correct 80 ms 4444 KB Output is correct
54 Correct 77 ms 4444 KB Output is correct
55 Correct 12 ms 4440 KB Output is correct
56 Correct 67 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 47 ms 29744 KB Output is correct
3 Correct 45 ms 29776 KB Output is correct
4 Correct 33 ms 29776 KB Output is correct
5 Correct 48 ms 29780 KB Output is correct
6 Correct 35 ms 29784 KB Output is correct
7 Correct 50 ms 29724 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 12 ms 4560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 47 ms 29744 KB Output is correct
3 Correct 45 ms 29776 KB Output is correct
4 Correct 33 ms 29776 KB Output is correct
5 Correct 48 ms 29780 KB Output is correct
6 Correct 35 ms 29784 KB Output is correct
7 Correct 50 ms 29724 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 12 ms 4560 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 160 ms 29640 KB Output is correct
21 Correct 145 ms 34900 KB Output is correct
22 Correct 146 ms 34900 KB Output is correct
23 Correct 156 ms 35924 KB Output is correct
24 Correct 139 ms 35512 KB Output is correct
25 Correct 178 ms 35536 KB Output is correct
26 Correct 171 ms 35420 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 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 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 47 ms 29744 KB Output is correct
3 Correct 45 ms 29776 KB Output is correct
4 Correct 33 ms 29776 KB Output is correct
5 Correct 48 ms 29780 KB Output is correct
6 Correct 35 ms 29784 KB Output is correct
7 Correct 50 ms 29724 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 12 ms 4560 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 160 ms 29640 KB Output is correct
21 Correct 145 ms 34900 KB Output is correct
22 Correct 146 ms 34900 KB Output is correct
23 Correct 156 ms 35924 KB Output is correct
24 Correct 139 ms 35512 KB Output is correct
25 Correct 178 ms 35536 KB Output is correct
26 Correct 171 ms 35420 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 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 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Incorrect 201 ms 37196 KB Output isn't correct
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 47 ms 29744 KB Output is correct
3 Correct 45 ms 29776 KB Output is correct
4 Correct 33 ms 29776 KB Output is correct
5 Correct 48 ms 29780 KB Output is correct
6 Correct 35 ms 29784 KB Output is correct
7 Correct 50 ms 29724 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 12 ms 4560 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 160 ms 29640 KB Output is correct
21 Correct 145 ms 34900 KB Output is correct
22 Correct 146 ms 34900 KB Output is correct
23 Correct 156 ms 35924 KB Output is correct
24 Correct 139 ms 35512 KB Output is correct
25 Correct 178 ms 35536 KB Output is correct
26 Correct 171 ms 35420 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 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 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Incorrect 201 ms 37196 KB Output isn't correct
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2460 KB Output is correct
39 Correct 0 ms 2396 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 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 76 ms 4444 KB Output is correct
52 Correct 81 ms 4696 KB Output is correct
53 Correct 80 ms 4444 KB Output is correct
54 Correct 77 ms 4444 KB Output is correct
55 Correct 12 ms 4440 KB Output is correct
56 Correct 67 ms 4444 KB Output is correct
57 Correct 0 ms 2392 KB Output is correct
58 Correct 47 ms 29744 KB Output is correct
59 Correct 45 ms 29776 KB Output is correct
60 Correct 33 ms 29776 KB Output is correct
61 Correct 48 ms 29780 KB Output is correct
62 Correct 35 ms 29784 KB Output is correct
63 Correct 50 ms 29724 KB Output is correct
64 Correct 1 ms 2392 KB Output is correct
65 Correct 0 ms 2392 KB Output is correct
66 Correct 0 ms 2396 KB Output is correct
67 Correct 0 ms 2396 KB Output is correct
68 Correct 1 ms 2396 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 1 ms 2392 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
73 Correct 12 ms 4560 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 0 ms 2396 KB Output is correct
76 Correct 160 ms 29640 KB Output is correct
77 Correct 145 ms 34900 KB Output is correct
78 Correct 146 ms 34900 KB Output is correct
79 Correct 156 ms 35924 KB Output is correct
80 Correct 139 ms 35512 KB Output is correct
81 Correct 178 ms 35536 KB Output is correct
82 Correct 171 ms 35420 KB Output is correct
83 Correct 1 ms 2392 KB Output is correct
84 Correct 1 ms 2392 KB Output is correct
85 Correct 1 ms 2396 KB Output is correct
86 Correct 1 ms 2396 KB Output is correct
87 Correct 1 ms 2396 KB Output is correct
88 Correct 1 ms 2396 KB Output is correct
89 Correct 1 ms 2652 KB Output is correct
90 Correct 1 ms 2396 KB Output is correct
91 Correct 1 ms 2396 KB Output is correct
92 Correct 1 ms 2396 KB Output is correct
93 Correct 1 ms 2392 KB Output is correct
94 Correct 1 ms 2396 KB Output is correct
95 Correct 1 ms 2396 KB Output is correct
96 Correct 1 ms 2392 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 2396 KB Output is correct
100 Correct 1 ms 2396 KB Output is correct
101 Correct 1 ms 2396 KB Output is correct
102 Correct 1 ms 2396 KB Output is correct
103 Incorrect 201 ms 37196 KB Output isn't correct
104 Halted 0 ms 0 KB -