Submission #1077590

# Submission time Handle Problem Language Result Execution time Memory
1077590 2024-08-27T08:08:46 Z vjudge1 Council (JOI23_council) C++17
56 / 100
4000 ms 33232 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<int,int>ma;
int sum[2000000];
int p[2000000],pp[2000000];
int co[2000000];
int val[2000000];
 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];
	
	 for(int i=0;i<m;i++)
	 co[i]=0;
	
	 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]]++;
	 }
	 vector<int>v;
	 for(auto i:ma)
	 v.push_back(i.first);
	 int l=v.size();
	
	 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]);
		 if(ma[v[i]]>1)
		 {
			 sum[v[i]]=ans-p[i]-pp[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]]=max(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:34:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   34 |  if(a[i][y]==1)
      |  ^~
council.cpp:36:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   36 |    val[i]+=(1<<y)*a[i][y];
      |    ^~~
council.cpp:60:7: warning: variable 'o' set but not used [-Wunused-but-set-variable]
   60 |   int o[l];
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 6 ms 860 KB Output is correct
52 Correct 6 ms 736 KB Output is correct
53 Correct 30 ms 4936 KB Output is correct
54 Correct 30 ms 4700 KB Output is correct
55 Correct 4 ms 348 KB Output is correct
56 Correct 27 ms 1328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 333 ms 5700 KB Output is correct
3 Correct 323 ms 5712 KB Output is correct
4 Correct 301 ms 3920 KB Output is correct
5 Correct 326 ms 5716 KB Output is correct
6 Correct 330 ms 3924 KB Output is correct
7 Correct 361 ms 5716 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 333 ms 5700 KB Output is correct
3 Correct 323 ms 5712 KB Output is correct
4 Correct 301 ms 3920 KB Output is correct
5 Correct 326 ms 5716 KB Output is correct
6 Correct 330 ms 3924 KB Output is correct
7 Correct 361 ms 5716 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 453 ms 19636 KB Output is correct
21 Correct 413 ms 17948 KB Output is correct
22 Correct 425 ms 18008 KB Output is correct
23 Correct 432 ms 20016 KB Output is correct
24 Correct 449 ms 19712 KB Output is correct
25 Correct 478 ms 19928 KB Output is correct
26 Correct 458 ms 19924 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 333 ms 5700 KB Output is correct
3 Correct 323 ms 5712 KB Output is correct
4 Correct 301 ms 3920 KB Output is correct
5 Correct 326 ms 5716 KB Output is correct
6 Correct 330 ms 3924 KB Output is correct
7 Correct 361 ms 5716 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 453 ms 19636 KB Output is correct
21 Correct 413 ms 17948 KB Output is correct
22 Correct 425 ms 18008 KB Output is correct
23 Correct 432 ms 20016 KB Output is correct
24 Correct 449 ms 19712 KB Output is correct
25 Correct 478 ms 19928 KB Output is correct
26 Correct 458 ms 19924 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 530 ms 26964 KB Output is correct
48 Correct 485 ms 25172 KB Output is correct
49 Correct 494 ms 25240 KB Output is correct
50 Correct 445 ms 27224 KB Output is correct
51 Correct 476 ms 26812 KB Output is correct
52 Correct 1097 ms 27984 KB Output is correct
53 Correct 1120 ms 28348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 333 ms 5700 KB Output is correct
3 Correct 323 ms 5712 KB Output is correct
4 Correct 301 ms 3920 KB Output is correct
5 Correct 326 ms 5716 KB Output is correct
6 Correct 330 ms 3924 KB Output is correct
7 Correct 361 ms 5716 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 453 ms 19636 KB Output is correct
21 Correct 413 ms 17948 KB Output is correct
22 Correct 425 ms 18008 KB Output is correct
23 Correct 432 ms 20016 KB Output is correct
24 Correct 449 ms 19712 KB Output is correct
25 Correct 478 ms 19928 KB Output is correct
26 Correct 458 ms 19924 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 530 ms 26964 KB Output is correct
48 Correct 485 ms 25172 KB Output is correct
49 Correct 494 ms 25240 KB Output is correct
50 Correct 445 ms 27224 KB Output is correct
51 Correct 476 ms 26812 KB Output is correct
52 Correct 1097 ms 27984 KB Output is correct
53 Correct 1120 ms 28348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Execution timed out 4043 ms 33232 KB Time limit exceeded
60 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 1624 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 6 ms 860 KB Output is correct
52 Correct 6 ms 736 KB Output is correct
53 Correct 30 ms 4936 KB Output is correct
54 Correct 30 ms 4700 KB Output is correct
55 Correct 4 ms 348 KB Output is correct
56 Correct 27 ms 1328 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 333 ms 5700 KB Output is correct
59 Correct 323 ms 5712 KB Output is correct
60 Correct 301 ms 3920 KB Output is correct
61 Correct 326 ms 5716 KB Output is correct
62 Correct 330 ms 3924 KB Output is correct
63 Correct 361 ms 5716 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 1 ms 372 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 3 ms 348 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Correct 453 ms 19636 KB Output is correct
77 Correct 413 ms 17948 KB Output is correct
78 Correct 425 ms 18008 KB Output is correct
79 Correct 432 ms 20016 KB Output is correct
80 Correct 449 ms 19712 KB Output is correct
81 Correct 478 ms 19928 KB Output is correct
82 Correct 458 ms 19924 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 1 ms 348 KB Output is correct
86 Correct 1 ms 348 KB Output is correct
87 Correct 1 ms 348 KB Output is correct
88 Correct 0 ms 468 KB Output is correct
89 Correct 1 ms 348 KB Output is correct
90 Correct 1 ms 344 KB Output is correct
91 Correct 1 ms 348 KB Output is correct
92 Correct 2 ms 348 KB Output is correct
93 Correct 0 ms 348 KB Output is correct
94 Correct 1 ms 348 KB Output is correct
95 Correct 1 ms 344 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 0 ms 348 KB Output is correct
98 Correct 1 ms 344 KB Output is correct
99 Correct 0 ms 348 KB Output is correct
100 Correct 1 ms 348 KB Output is correct
101 Correct 1 ms 348 KB Output is correct
102 Correct 0 ms 344 KB Output is correct
103 Correct 530 ms 26964 KB Output is correct
104 Correct 485 ms 25172 KB Output is correct
105 Correct 494 ms 25240 KB Output is correct
106 Correct 445 ms 27224 KB Output is correct
107 Correct 476 ms 26812 KB Output is correct
108 Correct 1097 ms 27984 KB Output is correct
109 Correct 1120 ms 28348 KB Output is correct
110 Correct 1 ms 348 KB Output is correct
111 Correct 0 ms 348 KB Output is correct
112 Correct 1 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 0 ms 348 KB Output is correct
115 Execution timed out 4043 ms 33232 KB Time limit exceeded
116 Halted 0 ms 0 KB -