Submission #484441

#TimeUsernameProblemLanguageResultExecution timeMemory
484441PoPularPlusPlusPoi (IOI09_poi)C++17
100 / 100
236 ms23744 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}

bool cmp(pair<int,pair<int,int>> x , pair<int,pair<int,int>> y){
	if(x.vf != y.vf)return x.vf > y.vf;
	if(x.vs.vf != y.vs.vf)return x.vs.vf > y.vs.vf;
	return x.vs.vs < y.vs.vs;
}

void solve(){
	int n,t,p;
	cin >> n >> t >> p;
	p--;
	int arr[n][t];
	int c[n] , cnt[t];
	memset(c,0,sizeof c);
	memset(cnt,0,sizeof cnt);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < t; j++){
			cin >> arr[i][j];
			if(arr[i][j] == 1)c[i]++,cnt[j]++;
		}
	}
	vector<pair<int,pair<int,int>>> v;
	for(int i = 0; i < n; i++){
		int points = 0;
		for(int j = 0; j < t; j++){
			if(arr[i][j] == 1){
				points += n - cnt[j];
			}
		}
		v.pb(mp(points , mp(c[i] , i)));
	}
	sort(all(v) , cmp);
	int a,b;
	for(int i = 0; i < n; i++){
		if(v[i].vs.vs == p){
			a = v[i].vf;
			b = i + 1;
		}
	}
	cout << a << ' ' << b << '\n';
}	

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
	//int t;cin >> t;while(t--)
	solve();
	return 0;
}

Compilation message (stderr)

poi.cpp: In function 'void solve()':
poi.cpp:56:15: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |  cout << a << ' ' << b << '\n';
      |               ^~~
poi.cpp:56:27: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |  cout << a << ' ' << b << '\n';
      |                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...