제출 #539524

#제출 시각아이디문제언어결과실행 시간메모리
539524MurotYPoi (IOI09_poi)C++14
100 / 100
356 ms31756 KiB
#include <bits/stdc++.h> #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ff first #define ss second #define ll long long using namespace std; const int N=2*1e3+7, M=1e9+7; ll a[N][N], b[N]; pair <ll, pair <ll,ll>> ans[N]; void solve() { ll n, m, p; cin >> n >> m >> p; for (int i=1;i<=n;i++) ans[i].ff=ans[i].ss.ff=ans[i].ss.ss=0; for (int i=1;i<=m;i++) b[i]=0; for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++) cin >> a[i][j]; } for (int j=1;j<=m;j++){ for (int i=1;i<=n;i++){ if (a[i][j] == 0) b[j]++; } } for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++){ if (a[i][j] == 1) ans[i].ff+=b[j]; if (a[i][j] == 1) ans[i].ss.ff++; } ans[i].ss.ss=i; } sort(ans+1,ans+n+1); for (int i=1;i<=n;i++){ for (int j=i;j<=n;j++){ if (ans[i].ff != ans[j].ff || ans[i].ss.ff != ans[j].ss.ff) { reverse(ans+i, ans+j); i=j-1; break; } } } for (int i=n;i>=1;i--){ // cout << ans[i].ff <<" " << ans[i].ss.ff <<" " << ans[i].ss.ss <<"\n"; if (ans[i].ss.ss == p){ cout << ans[i].ff << " " << n-i+1; return ; } } return ; } int main() { ios; int t=1; // cin >> t; while (t--){ solve(); cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...