Submission #931470

# Submission time Handle Problem Language Result Execution time Memory
931470 2024-02-21T21:25:55 Z emad234 Poi (IOI09_poi) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define   ll long long
#define F first
#define S second
#define pii pair<int,int>
const int mod = 1e9 + 7;
const int mxN = 2e5 + 5;
using namespace std;
struct ranking{
	int score,num,id;
};
ranking ans[mxN];
bool operator<(ranking a,ranking b){
	return tie(a.score,a.num,-1 * a.id) > tie(b.score,b.num,-1 * b.id);
}
bool operator==(ranking a,ranking b){
	return tie(a.score,a.num,a.id) == tie(b.score,b.num,b.id);
}
int p[mxN];
int a[2021][2021];
signed main(){
	int n,t,P;
	cin >>n>>t>>P;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= t;j++){
			cin >>a[i][j];
			if(!a[i][j]) p[j]++;
		}
	}
	for(int i = 1;i <= n;i++){
		ans[i].id = {i};
		for(int j = 1;j <= t;j++){
			ans[i].num += (a[i][j]);
			ans[i].score += (p[j] * a[i][j]);
		}
	}
	sort(ans + 1,ans + n + 1);
	for(int i = 1;i <= n;i++){
		if(ans[i].id == P){
			cout<<ans[i].score<<' '<<i;
			return 0;
		}
	}
}

Compilation message

poi.cpp: In function 'bool operator<(ranking, ranking)':
poi.cpp:14:30: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   14 |  return tie(a.score,a.num,-1 * a.id) > tie(b.score,b.num,-1 * b.id);
      |                           ~~~^~~~~~
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from poi.cpp:1:
/usr/include/c++/10/tuple:1615:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1615 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~
poi.cpp:14:61: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   14 |  return tie(a.score,a.num,-1 * a.id) > tie(b.score,b.num,-1 * b.id);
      |                                                          ~~~^~~~~~
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from poi.cpp:1:
/usr/include/c++/10/tuple:1615:19: note:   initializing argument 3 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]'
 1615 |     tie(_Elements&... __args) noexcept
      |         ~~~~~~~~~~^~~~~~~~~~