답안 #1077555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077555 2024-08-27T08:00:42 Z vjudge1 Council (JOI23_council) C++
40 / 100
4000 ms 14420 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
const ll M=5e5+10;
const ll inf=2e18+10;
const ll mod=1e9+7;
ll n,m,a[M],cnt[M],cntb[40];
int main() {
  ios_base::sync_with_stdio(0),cin.tie(0);
  cin>>n>>m;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) {
      ll x;
      cin>>x;
      a[i]+=(x*(1<<j));
      cntb[j]+=x;
    }
  for(int i=0;i<n;i++) {
    for(int j=a[i];j<(1<<m);j++,j|=a[i]) {
      cnt[j]++;
    }
  }
  for(int i=0;i<n;i++) {
    ll res=0,x=0;
    for(int j=0;j<m;j++) {
      if(cntb[j]-bool(((1<<j)&a[i])>0)>n/2)
        res++;
      else if(cntb[j]-bool(((1<<j)&a[i])>0)==n/2) {
        x+=(1<<j);
      }
    }
    ll res1=0;
    for(int j=x;j>=0;j--) {
      if(j<0)
        break;
      j&=x;
      ll y=j+(((1<<m)-1)^x);
      if((a[i]&y)==a[i])
        cnt[y]--;
      if(cnt[y]>0)
        res1=max(res1,(ll)__builtin_popcountll(x)-__builtin_popcountll(j));
      if((a[i]&y)==a[i])
        cnt[y]++;
    }
    cout<<res1+res<<'\n';
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 5 ms 3932 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 5 ms 3932 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 38 ms 3228 KB Output is correct
3 Correct 38 ms 4452 KB Output is correct
4 Correct 48 ms 3916 KB Output is correct
5 Correct 40 ms 4440 KB Output is correct
6 Correct 31 ms 3760 KB Output is correct
7 Correct 46 ms 4436 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 38 ms 3228 KB Output is correct
3 Correct 38 ms 4452 KB Output is correct
4 Correct 48 ms 3916 KB Output is correct
5 Correct 40 ms 4440 KB Output is correct
6 Correct 31 ms 3760 KB Output is correct
7 Correct 46 ms 4436 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 204 ms 9044 KB Output is correct
21 Correct 191 ms 8656 KB Output is correct
22 Correct 185 ms 8440 KB Output is correct
23 Correct 144 ms 9360 KB Output is correct
24 Correct 353 ms 9180 KB Output is correct
25 Correct 172 ms 9044 KB Output is correct
26 Correct 265 ms 9040 KB Output is correct
27 Correct 1 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 1 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 1 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 464 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 38 ms 3228 KB Output is correct
3 Correct 38 ms 4452 KB Output is correct
4 Correct 48 ms 3916 KB Output is correct
5 Correct 40 ms 4440 KB Output is correct
6 Correct 31 ms 3760 KB Output is correct
7 Correct 46 ms 4436 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 204 ms 9044 KB Output is correct
21 Correct 191 ms 8656 KB Output is correct
22 Correct 185 ms 8440 KB Output is correct
23 Correct 144 ms 9360 KB Output is correct
24 Correct 353 ms 9180 KB Output is correct
25 Correct 172 ms 9044 KB Output is correct
26 Correct 265 ms 9040 KB Output is correct
27 Correct 1 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 1 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 1 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 464 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 398 ms 11688 KB Output is correct
48 Correct 399 ms 10944 KB Output is correct
49 Correct 331 ms 11076 KB Output is correct
50 Correct 214 ms 11884 KB Output is correct
51 Correct 3741 ms 11656 KB Output is correct
52 Correct 278 ms 11508 KB Output is correct
53 Correct 676 ms 11860 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 38 ms 3228 KB Output is correct
3 Correct 38 ms 4452 KB Output is correct
4 Correct 48 ms 3916 KB Output is correct
5 Correct 40 ms 4440 KB Output is correct
6 Correct 31 ms 3760 KB Output is correct
7 Correct 46 ms 4436 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 204 ms 9044 KB Output is correct
21 Correct 191 ms 8656 KB Output is correct
22 Correct 185 ms 8440 KB Output is correct
23 Correct 144 ms 9360 KB Output is correct
24 Correct 353 ms 9180 KB Output is correct
25 Correct 172 ms 9044 KB Output is correct
26 Correct 265 ms 9040 KB Output is correct
27 Correct 1 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 1 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 1 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 464 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 398 ms 11688 KB Output is correct
48 Correct 399 ms 10944 KB Output is correct
49 Correct 331 ms 11076 KB Output is correct
50 Correct 214 ms 11884 KB Output is correct
51 Correct 3741 ms 11656 KB Output is correct
52 Correct 278 ms 11508 KB Output is correct
53 Correct 676 ms 11860 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 250 ms 13584 KB Output is correct
60 Correct 662 ms 6484 KB Output is correct
61 Correct 733 ms 6740 KB Output is correct
62 Correct 820 ms 6996 KB Output is correct
63 Correct 721 ms 13220 KB Output is correct
64 Correct 1139 ms 14392 KB Output is correct
65 Correct 1000 ms 14420 KB Output is correct
66 Correct 198 ms 13696 KB Output is correct
67 Execution timed out 4048 ms 13648 KB Time limit exceeded
68 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 5 ms 3932 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -