Submission #889581

#TimeUsernameProblemLanguageResultExecution timeMemory
889581vjudge1Council (JOI23_council)C++17
16 / 100
4066 ms16884 KiB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m; cin >> n >> m;
    vector <vector<int>> a(n, vector <int> (m));
    for ( auto &u: a ){
        for ( auto &v: u ) cin >> v;
    }
    vector <int> cnt(m);
    for ( int i = 0; i < n; i++ ){
        for ( int j = 0; j < m; j++ ){
            cnt[j] += a[i][j];
        }
    }
    int tot = 0;
    for ( auto &x: cnt ){
        tot += (x >= n / 2);
    }
    for ( int i = 0; i < n; i++ ){
        int mx = 0, q = tot;
        auto tmp = cnt;
        for ( int j = 0; j < m; j++ ){
            if ( a[i][j] && cnt[j] == n / 2 ){
                --q;
            } cnt[j] -= a[i][j];
        }
        for ( int j = 0; j < n; j++ ){
            if ( j == i ) continue;
            int tq = q;
            for ( int k = 0; k < m; k++ ){
                if ( a[j][k] && cnt[k] == n / 2 ){
                    --tq;
                }
            }
            chmax(mx, tq);
        }
        cout << mx << ln;
        swap(tmp, cnt);
    }

    cout << '\n';
}
#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...