Submission #907206

# Submission time Handle Problem Language Result Execution time Memory
907206 2024-01-15T08:39:46 Z vjudge1 Council (JOI23_council) C++17
0 / 100
83 ms 31524 KB
#include<bits/stdc++.h>
using namespace std;

struct trie{
	int s[2];
}tre[300000*10];

int b[300100][25],msum[25];
int cnt=0;
int n,m;
int nw[25];

void insert(int which){
	int nw=0;
	for (int i=1;i<=m;i++){
		int tp=b[which][i];
		if (!tre[nw].s[tp]){
			tre[nw].s[tp]=++cnt;
		}
		//printf("%d %d\n",tp,tre[nw].s[tp]);
		nw=tre[nw].s[tp];
	}
}

int fd(int level,int tnum,int l,bool same,int em){
	if (l<0){
		return -99999;
	}
	if (level>m){
		if (same) return -99999;
		return 0;
	}
	int ans=0;
	if (tre[tnum].s[0]){
		int tp=0;
		if (nw[level]==1){
			tp++;
		}
		tp+=fd(level+1,tre[tnum].s[0],l,same&&b[em][level]==0,em);
		ans=tp;
	}
	int emmmm=0;
	if (tre[tnum].s[1]){
		int tp=0;
		if (nw[level]==1){
			emmmm=1;
		}
		tp=fd(level+1,tre[tnum].s[1],l-emmmm,same&&b[em][level]==1,em);
		ans=max(tp,ans);
	}
	//printf("%d %d %d\n",level,l,ans);
	return ans;
}

int main(){
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++){
		for (int p=1;p<=m;p++){
			scanf("%d",&b[i][p]);
			msum[p]+=b[i][p];
		}
		insert(i);
	}
	for (int i=1;i<=n;i++){
		int ans=0,ct=0;
		memset(nw,0,sizeof nw);
		for (int p=1;p<=m;p++){
			msum[p]-=b[i][p];
			if (msum[p]==n/2){
				nw[p]=1;
				ct++;
			}
			else if (msum[p]>n/2){
				ans++;
			}
		}
		int tpans=0;
		for (int p=0;p<=ct;p++){
			int tps=fd(1,0,p,true,i);
			if (tps>0){
				tpans=tps;
				break;
			}
		}
		for (int p=1;p<=m;p++){
			msum[p]+=b[i][p];
		}
		printf("%d\n",ans+tpans);
	}
}

Compilation message

council.cpp: In function 'int main()':
council.cpp:56:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |  scanf("%d %d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~
council.cpp:59:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |    scanf("%d",&b[i][p]);
      |    ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 72 ms 31316 KB Output is correct
3 Correct 69 ms 31320 KB Output is correct
4 Correct 51 ms 30772 KB Output is correct
5 Correct 83 ms 31524 KB Output is correct
6 Incorrect 57 ms 30804 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 72 ms 31316 KB Output is correct
3 Correct 69 ms 31320 KB Output is correct
4 Correct 51 ms 30772 KB Output is correct
5 Correct 83 ms 31524 KB Output is correct
6 Incorrect 57 ms 30804 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 72 ms 31316 KB Output is correct
3 Correct 69 ms 31320 KB Output is correct
4 Correct 51 ms 30772 KB Output is correct
5 Correct 83 ms 31524 KB Output is correct
6 Incorrect 57 ms 30804 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 72 ms 31316 KB Output is correct
3 Correct 69 ms 31320 KB Output is correct
4 Correct 51 ms 30772 KB Output is correct
5 Correct 83 ms 31524 KB Output is correct
6 Incorrect 57 ms 30804 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -