Submission #953244

#TimeUsernameProblemLanguageResultExecution timeMemory
953244DearSimonePoi (IOI09_poi)C++17
85 / 100
177 ms23892 KiB
#include "bits/stdc++.h" using namespace std; typedef long long int64; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define dbg(x...) #endif const int MOD = 1000000007; void solve() { int contestants; cin >> contestants; int tasks; cin >> tasks; int p; cin >> p; vector<int> task_score(tasks, 0); vector<pair<int,int>> contestant_score(contestants, {0,0}); vector<int> solved_problems(contestants, 0); vector<vector<int>> inp; for (int i = 0; i < contestants; i++) { vector<int> temp; for (int j = 0; j < tasks; j++) { int curr; cin >> curr; task_score[j] += curr; temp.push_back(curr); } inp.push_back(temp); } for (int i = 0; i < tasks; i++) { task_score[i] = contestants - task_score[i]; } for (int i = 0; i < contestants; i++) { for (int j = 0; j < tasks; j++) { contestant_score[i].first += inp[i][j] * task_score[j]; contestant_score[i].second = i; solved_problems[i] += inp[i][j]; } } int score = contestant_score[p-1].first; cout << score << " "; sort(contestant_score.rbegin(), contestant_score.rend()); int indexOfTiebreak = 0; for (int i = 0; i < contestant_score.size(); i++) { if (contestant_score[i].first == score) { indexOfTiebreak = i; break; } } int solvedByP = solved_problems[p-1]; vector<pair<int,int>> indexes; for (int i = 0; i < contestants; i++) { if (contestant_score[i].first == score) indexes.push_back({ solved_problems[contestant_score[i].second], contestant_score[i].second} ); } sort(indexes.rbegin(), indexes.rend()); vector<int> tiebreak; for (int i = 0; i < indexes.size(); i++) { if (indexes[i].first == solvedByP) tiebreak.push_back(indexes[i].second); } if (tiebreak.size() == 1) { cout << indexOfTiebreak + 1 << " "; } else { sort(tiebreak.begin(), tiebreak.end()); int pos = 0; for (int i = 0; i < tiebreak.size(); i++) { if (tiebreak[i] == p - 1) { pos = i + 1; break; } } cout << indexOfTiebreak + pos << '\n'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int T = 1; while(T--) { solve(); } return 0; }

Compilation message (stderr)

poi.cpp: In function 'void solve()':
poi.cpp:78:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for (int i = 0; i < contestant_score.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~
poi.cpp:97:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |     for (int i = 0; i < indexes.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~
poi.cpp:107:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |         for (int i = 0; i < tiebreak.size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...