代码求调
查看原帖
代码求调
781159
Lovely_Elaina楼主2023/3/4 23:22

写完征文脑子一团乱麻,根本想不出哪里有问题

#include <bits/stdc++.h>
using namespace std;
const int N = 2010;

struct node{
    int num; // 编号
    int t;   // 得分(解决题目数量)
}a[N];

bool cmp(node a,node b){
    return (a.t==b.t?a.num<b.num:a.t>b.t);
}

int n,t,p,s[N];
bool b[N][N];

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    cin >> n >> t >> p;
    
    for(int i = 1; i <= n; i++){
        int x;
        for(int j = 1; j <= t; j++){
            cin >> x;
            b[i][j] = x;
            s[j] += x;
        }
        a[i].num = i;
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= t; j++){
            if(b[i][j]){
                a[i].t += (n-s[j]);
            }
        }
    }
    
    sort(a+1,a+1+n,cmp);
    
    for(int i = 1; i <= n; i++){
        if(a[i].num == p){
            cout << a[i].t << " " << i << endl;
            return 0;
        }
    }
    
    return 0;
}

预言:肯定是因为我傻逼了

2023/3/4 23:22
加载中...