# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953354 | DearSimone | Poi (IOI09_poi) | C++17 | 185 ms | 23948 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
bool isUnique(const vector<pair<int,int>>& v, int solved) {
int cnt = 0;
for (auto c: v) {
if (c.first == solved)
cnt++;
}
if (cnt > 1) return false;
return true;
}
int pos(const vector<pair<int,int>>& v, int solved) {
for (int i = 0; i < v.size(); i++) {
if (v[i].first == solved)
return i;
}
return -1;
}
int posIndex(const vector<pair<int,int>>& v, int solved) {
for (int i = 0; i < v.size(); i++) {
if (v[i].second == solved)
return i;
}
return -1;
}
bool sort1(pair<int,int> a, pair<int,int> b) {
if (a.first == b.first) {
return a.second < b.second;
}
return a.first > b.first;
}
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}
);
}
if (indexes.size() == 1) {
cout << indexOfTiebreak + 1 << '\n';
return;
}
sort(indexes.rbegin(), indexes.rend());
if (isUnique(indexes, solvedByP)) {
cout << indexOfTiebreak + pos(indexes, solvedByP) + 1 << '\n';
return;
}
sort(indexes.begin(), indexes.end(), sort1);
cout << indexOfTiebreak + posIndex(indexes, p - 1) + 1<< '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int T = 1;
while(T--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |