# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
907631 |
2024-01-16T00:45:51 Z |
vjudge1 |
Council (JOI23_council) |
C++17 |
|
4000 ms |
71764 KB |
#include<bits/stdc++.h>
using namespace std;
struct trie{
int s[2];
int numb=0;
}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];
}
tre[nw].numb++;
}
int fd(int level,int tnum,int l,int cur,int ult[]){
if (l<0){
return -99999;
}
if (level>m){
bool same=true;
for (int i=1;i<=m;i++){
if (ult[i]!=b[cur][i]){
same=false;
}
}
if (same&&tre[tnum].numb<=1) return -99999;
int ans=0;
for (int i=1;i<=m;i++){
if (ult[i]==0&&nw[i]==1){
ans++;
}
}
return ans;
}
int ans=0;
if (tre[tnum].s[0]){
ult[level]=0;
ans=max(ans,fd(level+1,tre[tnum].s[0],l,cur,ult));
}
int emmmm=0;
if (tre[tnum].s[1]){
ult[level]=1;
int tp=0;
if (nw[level]==1){
emmmm=1;
}
tp=fd(level+1,tre[tnum].s[1],l-emmmm,cur,ult);
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 emtary[30];
memset(emtary,0,sizeof emtary);
int tps=fd(1,0,p,i,emtary);
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:67:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | scanf("%d %d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~
council.cpp:70:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
70 | scanf("%d",&b[i][p]);
| ~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
35932 KB |
Output is correct |
2 |
Correct |
7 ms |
35932 KB |
Output is correct |
3 |
Correct |
7 ms |
35928 KB |
Output is correct |
4 |
Correct |
7 ms |
35932 KB |
Output is correct |
5 |
Correct |
7 ms |
36024 KB |
Output is correct |
6 |
Correct |
7 ms |
35932 KB |
Output is correct |
7 |
Correct |
7 ms |
36004 KB |
Output is correct |
8 |
Correct |
7 ms |
35932 KB |
Output is correct |
9 |
Correct |
14 ms |
35932 KB |
Output is correct |
10 |
Correct |
8 ms |
36044 KB |
Output is correct |
11 |
Correct |
8 ms |
35932 KB |
Output is correct |
12 |
Correct |
9 ms |
35932 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
7 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
7 ms |
35932 KB |
Output is correct |
18 |
Correct |
7 ms |
35932 KB |
Output is correct |
19 |
Correct |
7 ms |
36040 KB |
Output is correct |
20 |
Correct |
8 ms |
35932 KB |
Output is correct |
21 |
Correct |
8 ms |
35932 KB |
Output is correct |
22 |
Correct |
7 ms |
35932 KB |
Output is correct |
23 |
Correct |
7 ms |
35928 KB |
Output is correct |
24 |
Correct |
8 ms |
35928 KB |
Output is correct |
25 |
Correct |
7 ms |
35932 KB |
Output is correct |
26 |
Correct |
7 ms |
36040 KB |
Output is correct |
27 |
Correct |
6 ms |
36068 KB |
Output is correct |
28 |
Correct |
7 ms |
35932 KB |
Output is correct |
29 |
Correct |
7 ms |
35928 KB |
Output is correct |
30 |
Correct |
7 ms |
36052 KB |
Output is correct |
31 |
Correct |
10 ms |
35928 KB |
Output is correct |
32 |
Correct |
7 ms |
35932 KB |
Output is correct |
33 |
Correct |
7 ms |
35932 KB |
Output is correct |
34 |
Correct |
8 ms |
36312 KB |
Output is correct |
35 |
Correct |
7 ms |
35932 KB |
Output is correct |
36 |
Correct |
7 ms |
35932 KB |
Output is correct |
37 |
Correct |
7 ms |
35932 KB |
Output is correct |
38 |
Correct |
7 ms |
35932 KB |
Output is correct |
39 |
Correct |
7 ms |
35932 KB |
Output is correct |
40 |
Correct |
8 ms |
35932 KB |
Output is correct |
41 |
Correct |
7 ms |
35928 KB |
Output is correct |
42 |
Correct |
7 ms |
35932 KB |
Output is correct |
43 |
Correct |
7 ms |
35932 KB |
Output is correct |
44 |
Correct |
7 ms |
35928 KB |
Output is correct |
45 |
Correct |
7 ms |
35932 KB |
Output is correct |
46 |
Correct |
7 ms |
35932 KB |
Output is correct |
47 |
Correct |
7 ms |
36036 KB |
Output is correct |
48 |
Correct |
7 ms |
35932 KB |
Output is correct |
49 |
Correct |
7 ms |
36016 KB |
Output is correct |
50 |
Correct |
7 ms |
35932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
35932 KB |
Output is correct |
2 |
Correct |
7 ms |
35932 KB |
Output is correct |
3 |
Correct |
7 ms |
35928 KB |
Output is correct |
4 |
Correct |
7 ms |
35932 KB |
Output is correct |
5 |
Correct |
7 ms |
36024 KB |
Output is correct |
6 |
Correct |
7 ms |
35932 KB |
Output is correct |
7 |
Correct |
7 ms |
36004 KB |
Output is correct |
8 |
Correct |
7 ms |
35932 KB |
Output is correct |
9 |
Correct |
14 ms |
35932 KB |
Output is correct |
10 |
Correct |
8 ms |
36044 KB |
Output is correct |
11 |
Correct |
8 ms |
35932 KB |
Output is correct |
12 |
Correct |
9 ms |
35932 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
7 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
7 ms |
35932 KB |
Output is correct |
18 |
Correct |
7 ms |
35932 KB |
Output is correct |
19 |
Correct |
7 ms |
36040 KB |
Output is correct |
20 |
Correct |
8 ms |
35932 KB |
Output is correct |
21 |
Correct |
8 ms |
35932 KB |
Output is correct |
22 |
Correct |
7 ms |
35932 KB |
Output is correct |
23 |
Correct |
7 ms |
35928 KB |
Output is correct |
24 |
Correct |
8 ms |
35928 KB |
Output is correct |
25 |
Correct |
7 ms |
35932 KB |
Output is correct |
26 |
Correct |
7 ms |
36040 KB |
Output is correct |
27 |
Correct |
6 ms |
36068 KB |
Output is correct |
28 |
Correct |
7 ms |
35932 KB |
Output is correct |
29 |
Correct |
7 ms |
35928 KB |
Output is correct |
30 |
Correct |
7 ms |
36052 KB |
Output is correct |
31 |
Correct |
10 ms |
35928 KB |
Output is correct |
32 |
Correct |
7 ms |
35932 KB |
Output is correct |
33 |
Correct |
7 ms |
35932 KB |
Output is correct |
34 |
Correct |
8 ms |
36312 KB |
Output is correct |
35 |
Correct |
7 ms |
35932 KB |
Output is correct |
36 |
Correct |
7 ms |
35932 KB |
Output is correct |
37 |
Correct |
7 ms |
35932 KB |
Output is correct |
38 |
Correct |
7 ms |
35932 KB |
Output is correct |
39 |
Correct |
7 ms |
35932 KB |
Output is correct |
40 |
Correct |
8 ms |
35932 KB |
Output is correct |
41 |
Correct |
7 ms |
35928 KB |
Output is correct |
42 |
Correct |
7 ms |
35932 KB |
Output is correct |
43 |
Correct |
7 ms |
35932 KB |
Output is correct |
44 |
Correct |
7 ms |
35928 KB |
Output is correct |
45 |
Correct |
7 ms |
35932 KB |
Output is correct |
46 |
Correct |
7 ms |
35932 KB |
Output is correct |
47 |
Correct |
7 ms |
36036 KB |
Output is correct |
48 |
Correct |
7 ms |
35932 KB |
Output is correct |
49 |
Correct |
7 ms |
36016 KB |
Output is correct |
50 |
Correct |
7 ms |
35932 KB |
Output is correct |
51 |
Correct |
12 ms |
38236 KB |
Output is correct |
52 |
Correct |
12 ms |
38236 KB |
Output is correct |
53 |
Correct |
1612 ms |
38700 KB |
Output is correct |
54 |
Correct |
41 ms |
38232 KB |
Output is correct |
55 |
Correct |
9 ms |
38232 KB |
Output is correct |
56 |
Correct |
39 ms |
38452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
35932 KB |
Output is correct |
2 |
Correct |
85 ms |
65504 KB |
Output is correct |
3 |
Correct |
81 ms |
65476 KB |
Output is correct |
4 |
Correct |
63 ms |
65360 KB |
Output is correct |
5 |
Correct |
92 ms |
65472 KB |
Output is correct |
6 |
Correct |
64 ms |
65364 KB |
Output is correct |
7 |
Correct |
98 ms |
66680 KB |
Output is correct |
8 |
Correct |
7 ms |
35928 KB |
Output is correct |
9 |
Correct |
8 ms |
36188 KB |
Output is correct |
10 |
Correct |
7 ms |
35928 KB |
Output is correct |
11 |
Correct |
7 ms |
35932 KB |
Output is correct |
12 |
Correct |
7 ms |
36112 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
6 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
8 ms |
38128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
35932 KB |
Output is correct |
2 |
Correct |
85 ms |
65504 KB |
Output is correct |
3 |
Correct |
81 ms |
65476 KB |
Output is correct |
4 |
Correct |
63 ms |
65360 KB |
Output is correct |
5 |
Correct |
92 ms |
65472 KB |
Output is correct |
6 |
Correct |
64 ms |
65364 KB |
Output is correct |
7 |
Correct |
98 ms |
66680 KB |
Output is correct |
8 |
Correct |
7 ms |
35928 KB |
Output is correct |
9 |
Correct |
8 ms |
36188 KB |
Output is correct |
10 |
Correct |
7 ms |
35928 KB |
Output is correct |
11 |
Correct |
7 ms |
35932 KB |
Output is correct |
12 |
Correct |
7 ms |
36112 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
6 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
8 ms |
38128 KB |
Output is correct |
18 |
Correct |
7 ms |
35932 KB |
Output is correct |
19 |
Correct |
7 ms |
35932 KB |
Output is correct |
20 |
Correct |
392 ms |
71384 KB |
Output is correct |
21 |
Correct |
477 ms |
70740 KB |
Output is correct |
22 |
Correct |
298 ms |
70736 KB |
Output is correct |
23 |
Correct |
249 ms |
71764 KB |
Output is correct |
24 |
Correct |
253 ms |
71536 KB |
Output is correct |
25 |
Execution timed out |
4035 ms |
71464 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
35932 KB |
Output is correct |
2 |
Correct |
85 ms |
65504 KB |
Output is correct |
3 |
Correct |
81 ms |
65476 KB |
Output is correct |
4 |
Correct |
63 ms |
65360 KB |
Output is correct |
5 |
Correct |
92 ms |
65472 KB |
Output is correct |
6 |
Correct |
64 ms |
65364 KB |
Output is correct |
7 |
Correct |
98 ms |
66680 KB |
Output is correct |
8 |
Correct |
7 ms |
35928 KB |
Output is correct |
9 |
Correct |
8 ms |
36188 KB |
Output is correct |
10 |
Correct |
7 ms |
35928 KB |
Output is correct |
11 |
Correct |
7 ms |
35932 KB |
Output is correct |
12 |
Correct |
7 ms |
36112 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
6 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
8 ms |
38128 KB |
Output is correct |
18 |
Correct |
7 ms |
35932 KB |
Output is correct |
19 |
Correct |
7 ms |
35932 KB |
Output is correct |
20 |
Correct |
392 ms |
71384 KB |
Output is correct |
21 |
Correct |
477 ms |
70740 KB |
Output is correct |
22 |
Correct |
298 ms |
70736 KB |
Output is correct |
23 |
Correct |
249 ms |
71764 KB |
Output is correct |
24 |
Correct |
253 ms |
71536 KB |
Output is correct |
25 |
Execution timed out |
4035 ms |
71464 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
35932 KB |
Output is correct |
2 |
Correct |
85 ms |
65504 KB |
Output is correct |
3 |
Correct |
81 ms |
65476 KB |
Output is correct |
4 |
Correct |
63 ms |
65360 KB |
Output is correct |
5 |
Correct |
92 ms |
65472 KB |
Output is correct |
6 |
Correct |
64 ms |
65364 KB |
Output is correct |
7 |
Correct |
98 ms |
66680 KB |
Output is correct |
8 |
Correct |
7 ms |
35928 KB |
Output is correct |
9 |
Correct |
8 ms |
36188 KB |
Output is correct |
10 |
Correct |
7 ms |
35928 KB |
Output is correct |
11 |
Correct |
7 ms |
35932 KB |
Output is correct |
12 |
Correct |
7 ms |
36112 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
6 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
8 ms |
38128 KB |
Output is correct |
18 |
Correct |
7 ms |
35932 KB |
Output is correct |
19 |
Correct |
7 ms |
35932 KB |
Output is correct |
20 |
Correct |
392 ms |
71384 KB |
Output is correct |
21 |
Correct |
477 ms |
70740 KB |
Output is correct |
22 |
Correct |
298 ms |
70736 KB |
Output is correct |
23 |
Correct |
249 ms |
71764 KB |
Output is correct |
24 |
Correct |
253 ms |
71536 KB |
Output is correct |
25 |
Execution timed out |
4035 ms |
71464 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
35932 KB |
Output is correct |
2 |
Correct |
7 ms |
35932 KB |
Output is correct |
3 |
Correct |
7 ms |
35928 KB |
Output is correct |
4 |
Correct |
7 ms |
35932 KB |
Output is correct |
5 |
Correct |
7 ms |
36024 KB |
Output is correct |
6 |
Correct |
7 ms |
35932 KB |
Output is correct |
7 |
Correct |
7 ms |
36004 KB |
Output is correct |
8 |
Correct |
7 ms |
35932 KB |
Output is correct |
9 |
Correct |
14 ms |
35932 KB |
Output is correct |
10 |
Correct |
8 ms |
36044 KB |
Output is correct |
11 |
Correct |
8 ms |
35932 KB |
Output is correct |
12 |
Correct |
9 ms |
35932 KB |
Output is correct |
13 |
Correct |
7 ms |
35932 KB |
Output is correct |
14 |
Correct |
7 ms |
35932 KB |
Output is correct |
15 |
Correct |
7 ms |
35932 KB |
Output is correct |
16 |
Correct |
7 ms |
35932 KB |
Output is correct |
17 |
Correct |
7 ms |
35932 KB |
Output is correct |
18 |
Correct |
7 ms |
35932 KB |
Output is correct |
19 |
Correct |
7 ms |
36040 KB |
Output is correct |
20 |
Correct |
8 ms |
35932 KB |
Output is correct |
21 |
Correct |
8 ms |
35932 KB |
Output is correct |
22 |
Correct |
7 ms |
35932 KB |
Output is correct |
23 |
Correct |
7 ms |
35928 KB |
Output is correct |
24 |
Correct |
8 ms |
35928 KB |
Output is correct |
25 |
Correct |
7 ms |
35932 KB |
Output is correct |
26 |
Correct |
7 ms |
36040 KB |
Output is correct |
27 |
Correct |
6 ms |
36068 KB |
Output is correct |
28 |
Correct |
7 ms |
35932 KB |
Output is correct |
29 |
Correct |
7 ms |
35928 KB |
Output is correct |
30 |
Correct |
7 ms |
36052 KB |
Output is correct |
31 |
Correct |
10 ms |
35928 KB |
Output is correct |
32 |
Correct |
7 ms |
35932 KB |
Output is correct |
33 |
Correct |
7 ms |
35932 KB |
Output is correct |
34 |
Correct |
8 ms |
36312 KB |
Output is correct |
35 |
Correct |
7 ms |
35932 KB |
Output is correct |
36 |
Correct |
7 ms |
35932 KB |
Output is correct |
37 |
Correct |
7 ms |
35932 KB |
Output is correct |
38 |
Correct |
7 ms |
35932 KB |
Output is correct |
39 |
Correct |
7 ms |
35932 KB |
Output is correct |
40 |
Correct |
8 ms |
35932 KB |
Output is correct |
41 |
Correct |
7 ms |
35928 KB |
Output is correct |
42 |
Correct |
7 ms |
35932 KB |
Output is correct |
43 |
Correct |
7 ms |
35932 KB |
Output is correct |
44 |
Correct |
7 ms |
35928 KB |
Output is correct |
45 |
Correct |
7 ms |
35932 KB |
Output is correct |
46 |
Correct |
7 ms |
35932 KB |
Output is correct |
47 |
Correct |
7 ms |
36036 KB |
Output is correct |
48 |
Correct |
7 ms |
35932 KB |
Output is correct |
49 |
Correct |
7 ms |
36016 KB |
Output is correct |
50 |
Correct |
7 ms |
35932 KB |
Output is correct |
51 |
Correct |
12 ms |
38236 KB |
Output is correct |
52 |
Correct |
12 ms |
38236 KB |
Output is correct |
53 |
Correct |
1612 ms |
38700 KB |
Output is correct |
54 |
Correct |
41 ms |
38232 KB |
Output is correct |
55 |
Correct |
9 ms |
38232 KB |
Output is correct |
56 |
Correct |
39 ms |
38452 KB |
Output is correct |
57 |
Correct |
8 ms |
35932 KB |
Output is correct |
58 |
Correct |
85 ms |
65504 KB |
Output is correct |
59 |
Correct |
81 ms |
65476 KB |
Output is correct |
60 |
Correct |
63 ms |
65360 KB |
Output is correct |
61 |
Correct |
92 ms |
65472 KB |
Output is correct |
62 |
Correct |
64 ms |
65364 KB |
Output is correct |
63 |
Correct |
98 ms |
66680 KB |
Output is correct |
64 |
Correct |
7 ms |
35928 KB |
Output is correct |
65 |
Correct |
8 ms |
36188 KB |
Output is correct |
66 |
Correct |
7 ms |
35928 KB |
Output is correct |
67 |
Correct |
7 ms |
35932 KB |
Output is correct |
68 |
Correct |
7 ms |
36112 KB |
Output is correct |
69 |
Correct |
7 ms |
35932 KB |
Output is correct |
70 |
Correct |
7 ms |
35932 KB |
Output is correct |
71 |
Correct |
6 ms |
35932 KB |
Output is correct |
72 |
Correct |
7 ms |
35932 KB |
Output is correct |
73 |
Correct |
8 ms |
38128 KB |
Output is correct |
74 |
Correct |
7 ms |
35932 KB |
Output is correct |
75 |
Correct |
7 ms |
35932 KB |
Output is correct |
76 |
Correct |
392 ms |
71384 KB |
Output is correct |
77 |
Correct |
477 ms |
70740 KB |
Output is correct |
78 |
Correct |
298 ms |
70736 KB |
Output is correct |
79 |
Correct |
249 ms |
71764 KB |
Output is correct |
80 |
Correct |
253 ms |
71536 KB |
Output is correct |
81 |
Execution timed out |
4035 ms |
71464 KB |
Time limit exceeded |
82 |
Halted |
0 ms |
0 KB |
- |