#include <bits/stdc++.h>
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
#define int long long
using namespace std;
signed main(void) {
	exoworldgd;
  int n,m,p,rank = 0;
  cin >> n >> m >> p;
  int solved[n+1][m],w[m],score[n+1],cnt[n+1];
  memset(w,0,sizeof(w)),memset(score,0,sizeof(score)),memset(cnt,0,sizeof(cnt));
  for(int i = 1; i <= n; i++) for(int j = 0; j < m; j++) cin >> solved[i][j];
  for(int j = 0; j < m; j++) for(int i = 1; i <= n; i++) if(!solved[i][j]) w[j]++;
  for(int i = 1; i <= n; i++) for(int j = 0; j < m; j++) if(solved[i][j])score[i] += w[j],cnt[i]++;
  vector<tuple<int,int,int>> v;
  v.reserve(n);
  for(int i = 1; i <= n; i++) v.emplace_back(-score[i],-cnt[i],i);
  sort(v.begin(),v.end());
  for(int i = 0; i < n; i++) if(get<2>(v[i]) == p) { rank = i+1; break; }
  cout << score[p] << " " << rank;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |