QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#765747#6336. CouncilKiharaTouma6 164ms35464kbC++232.2kb2024-11-20 15:10:052024-11-20 15:10:05

Judging History

你现在查看的是最新测评结果

  • [2024-11-20 15:10:05]
  • 评测
  • 测评结果:6
  • 用时:164ms
  • 内存:35464kb
  • [2024-11-20 15:10:05]
  • 提交

answer

//qoj6336
#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 10;
int n, m, a[25][N], sum[25], v[N];
pair<int, int> f[N*4], g[N*4];

bool upd(int x, pair<int, int> y){
    if((f[x] > y || (f[x] == y && g[x] > y)) && f[x].second != y.second){
        g[x] = f[x];
        f[x] = y;
        return 1;
    } else if(g[x] > y && f[x].second != y.second){
        g[x] = y;
        return 1;
    }
    return 0;
}

int main(){
    for(int i = 0; i < N; ++ i){
        f[i].first = g[i].first = 2e9;
    }
    scanf("%d%d", &n, &m);
    queue<int> q;
    for(int i = 1; i <= n; ++ i){
        for(int j = 1; j <= m; ++ j){
            scanf("%d", &a[j][i]);
            sum[j] += a[j][i];
            v[i] |= (1 - a[j][i]) << j - 1;
        }
        upd(v[i], make_pair(0, i));
        // q.push(v[i]);
    }
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i = 0; i < m; ++ i){
            int v = 1 + (1 - ((x >> i) & 1)) * 100;
            if(upd(x^(1<<i), make_pair(f[x].first+v, f[x].second))){
                q.push(x ^ (1 << i));
            } else if(upd(x^(1<<i), make_pair(g[x].first+v, g[x].second))){
                q.push(x ^ (1 << i));
            }
        }
    }
    for(int i = 1; i <= n; ++ i){
        int val = 0, cnt = 0;
        for(int j = 1; j <= m; ++ j){
            if(sum[j] - a[j][i] == n / 2){
                val |= 1 << j - 1;
            } else if(sum[j] - a[j][i] > n / 2){
                ++ cnt;
            }
        }
        int mx = 0;
        // if(n <= 3000)
        // for(int j = 1; j <= n; ++ j){
        //     if(j != i){
        //         mx = max(mx, __builtin_popcount(val & v[j]));
        //     }
        // } else {

        if(f[val].second == i){
            // printf("%d ", g[val].second);
            mx = val & v[g[val].second];
        } else {
            // printf("%d ", f[val].second);
            mx = val & v[f[val].second];
        }
        mx = __builtin_popcount(mx);
        // }
        // printf("%d %d %d\n", cnt, mx, val);
        // printf("%d %d %d\n", val, f[val].second, f[val].first);
        printf("%d\n", mx + cnt);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 35464kb

input:

38 20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 ...

output:

0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
0
1
0
0
1
0
1
1
0
1
1
0
0
1
1
1
0
1
1
1
0
1
1

result:

wrong answer 1st numbers differ - expected: '18', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 6
Accepted

Test #53:

score: 6
Accepted
time: 40ms
memory: 18024kb

input:

300000 2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1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0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300000 numbers

Test #57:

score: 6
Accepted
time: 33ms
memory: 14824kb

input:

300000 1
1
0
1
1
1
0
1
1
1
1
0
0
1
0
1
0
0
0
1
1
1
1
0
0
0
1
1
0
0
0
0
0
1
1
0
1
0
1
1
1
0
0
1
0
1
0
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
1
0
0
1
1
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
1
1
1
1
1
1
0
1
0
0
1
1
1
0
0
1
1
0
0
1
1
0
1
0
0
0
1
1
1
0
1
0
1
1
1
1
1
1
0
1
0
1
1
1
1
1
0
1...

output:

0
1
0
0
0
1
0
0
0
0
1
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0
0
1
1
1
1
1
0
0
1
0
1
0
0
0
1
1
0
1
0
1
1
0
0
1
0
0
0
0
0
1
1
1
1
1
1
1
1
1
0
1
1
0
0
0
0
1
1
0
1
1
0
0
1
1
1
0
1
1
1
1
0
0
1
1
1
1
1
1
0
1
1
1
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
0
0
1
1
0
0
1
0
1
1
1
0
0
0
1
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
1
0
0
1
...

result:

ok 300000 numbers

Test #58:

score: 6
Accepted
time: 49ms
memory: 17812kb

input:

300000 2
0 0
0 0
1 0
0 1
0 0
1 1
1 0
0 1
1 0
1 0
0 1
1 1
0 0
0 1
0 0
1 1
1 1
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
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

wrong answer 242396th numbers differ - expected: '5', found: '0'

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%