Submission #768844

#TimeUsernameProblemLanguageResultExecution timeMemory
768844danikoynovCouncil (JOI23_council)C++14
16 / 100
4051 ms7464 KiB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 3e5 + 10, maxm = 21;
int n, m, imp[maxm], cnt[maxm];
bool a[maxn][maxm];
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
        for (int j = 0; j < m; j ++)
        cin >> a[i][j], cnt[j] += a[i][j];

    for (int i = 1; i <= n; i ++)
    {
        int base = 0;
        for (int j = 0; j < m; j ++)
        {
            int cur = cnt[j] - a[i][j];
            if (cur >= n / 2)
            {
                if ((cur - 1) < n / 2)
                imp[j] = 1;
                else
                    imp[j] = 0, base ++;
            }
            else
            {
                imp[j] = 0;
            }

        }

        /**cout << "----" << endl;
        cout << i << endl;
        for (int bit = 0; bit < m; bit ++)
            cout << imp[bit] << " ";
        cout << endl;*/
        int best = -m;
        for (int p = 1; p <= n; p ++)
        {
            if (p == i)
                continue;
                int sum = 0;
            for (int bit = 0; bit < m; bit ++)
            {
                if (imp[bit] == 1)
                {
                    if (a[p][bit] == 0)
                        sum ++;
                }
            }

            best = max(best, sum);
        }

        cout << base + best << endl;


    }
}

int main()
{
    speed();
    solve();
    return 0;
}

Compilation message (stderr)

council.cpp: In function 'void solve()':
council.cpp:60:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   60 |             if (p == i)
      |             ^~
council.cpp:62:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   62 |                 int sum = 0;
      |                 ^~~
#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...