제출 #1172481

#제출 시각아이디문제언어결과실행 시간메모리
1172481lopkusCouncil (JOI23_council)C++20
41 / 100
4096 ms30296 KiB
#include <bits/stdc++.h>+

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  std::vector<std::vector<int>> a(n, std::vector<int>(m));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      std::cin >> a[i][j];
    }
  }
  std::vector<int> cnt(m);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cnt[j] += a[i][j];
    }
  }
  std::vector<int> c(n, 0);
  std::vector<int> ans(n, 0);
  std::vector<int> b(n, 0);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      if(a[i][j] == 0) {
        b[i] |= (1LL << j);
      }
    }
  }
  std::vector<int> w((1LL << m), 0);
  for(int i = 0; i < n; i++) {
    w[b[i]] += 1;
  }
  for(int x = 0; x < n; x++) {
    for(int i = 0; i < m; i++) {
      if(cnt[i] >= n / 2 + 2) {
        ans[x] += 1;
        continue;
      }
      if(cnt[i] < n / 2) {
        continue;
      }
      if(a[x][i] && cnt[i] == n / 2) {
        continue;
      }
      if(!a[x][i] && cnt[i] == n / 2 + 1) {
        ans[x] += 1;
        continue;
      }
      c[x] |= (1LL << i);
    }
    int to = 0;
    if(n <= 3000) {
      for(int j = 0; j < n; j++) {
        if(x == j) {
          continue;
        }
        to = std::max(to, __builtin_popcount((b[j] & c[x])));
      }
    }
    else {
      for(int f = 0; f < (1LL << m); f++) {
      if(!w[f]) {
        continue;
      }
      if(b[x] == f && w[f] == 1) {
        continue;
      }
      to = std::max(to, __builtin_popcount((f & c[x])));
    }
    }
    std::cout << ans[x] + to << "\n";
  }
}

컴파일 시 표준 에러 (stderr) 메시지

council.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>+
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...