Submission #889123

# Submission time Handle Problem Language Result Execution time Memory
889123 2023-12-19T00:59:45 Z thunopro Council (JOI23_council) C++14
Compilation error
0 ms 0 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" ; 
}

bool 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] = true ; 
	}

	for ( int mask = 0 ; mask < (1<<m) ; mask ++ ) 
	{
		for ( int _mask = 0 ; _mask < (1<<m) ; _mask ++ ) 
		{
			if ( ! cnt [mask] || ! cnt[_mask] ) continue ; 
			if ( mask == _nmask && cnt [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 sub2()':
council.cpp:77:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   77 |    if ( ! cnt [mask] || ! cnt[_mask] ) continue ;
      |           ^~~
      |           int
council.cpp:78:17: error: '_nmask' was not declared in this scope; did you mean '_mask'?
   78 |    if ( mask == _nmask && cnt [mask] < 2 ) continue ;
      |                 ^~~~~~
      |                 _mask
council.cpp:78:27: error: 'cnt' was not declared in this scope; did you mean 'int'?
   78 |    if ( mask == _nmask && cnt [mask] < 2 ) continue ;
      |                           ^~~
      |                           int
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) ;
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~