Submission #1077554

# Submission time Handle Problem Language Result Execution time Memory
1077554 2024-08-27T08:00:30 Z vjudge1 Council (JOI23_council) C++17
0 / 100
417 ms 8724 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<int,int>ma;
int sum[1000000];
 int main()
 {
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 cout.tie(0);
	 int n,m;
	 cin>>n>>m;
	 int ans=0;
	 int a[n][m];
	 int co[m];
	 for(int i=0;i<m;i++)
	 co[i]=0;
	 int val[n];
	 for(int i=0;i<n;i++)
	 {
	 //co[i]=0;
	 val[i]=0;
 }
 
	 for(int i=0;i<n;i++)
	 {
		 for(int y=0;y<m;y++)
		 {
		 cin>>a[i][y];
	if(a[i][y]==1)
		 co[y]++;
		 val[i]+=(1<<y)*a[i][y];
		
	     }
	      ma[val[i]]=1;
	 }
	 vector<int>v;
	 for(auto i:ma)
	 v.push_back(i.first);
	 int l=v.size();
	 int p[l],pp[l];
	 int s1=0,s2=0;
	
	 for(int i=0;i<m;i++)
	 {
		 if(co[i]>=n/2)
		 ans++;
		 
		  if(co[i]<n/2)
		 continue;
		 else if(co[i]==n/2)
		 s1+=1<<i;
		 else if(co[i]==n/2+1)
		 s2+=1<<i;		 
	 }
	 int o[l];
	
//	cout<<s1<<' '<<s2<<endl;
	 for(int i=0;i<l;i++)
	 {
		 
		// cout<<i<<endl;
		 p[i]=v[i]&s1;
		 pp[i]=v[i]&s2;
		 o[i]=__builtin_popcount(p[i]);
		 int x=-1000000000;
		 //cout<<i<<' ';
		 for(int y=i-1;y>=0;y--)
		 {
			 //cout<<y<<endl;
			 int h=ans-__builtin_popcount(p[i]|p[y])-__builtin_popcount(pp[i]&pp[y]);
			 x=max(x,h);
			 sum[v[y]]=max(sum[v[y]],h);
		 }
		 sum[v[i]]=x;
		 
	 }
	 for(int i=0;i<n;i++)
	 cout<<sum[val[i]]<<endl;
	 
	
 }

Compilation message

council.cpp: In function 'int main()':
council.cpp:31:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |  if(a[i][y]==1)
      |  ^~
council.cpp:33:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |    val[i]+=(1<<y)*a[i][y];
      |    ^~~
council.cpp:57:7: warning: variable 'o' set but not used [-Wunused-but-set-variable]
   57 |   int o[l];
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 417 ms 8724 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 417 ms 8724 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 417 ms 8724 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 417 ms 8724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -