# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894611 | IWKR | Poi (IOI09_poi) | C++17 | 757 ms | 24504 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;
int main() {
int n, t, p;
cin >> n >> t >> p;
map<int, int> mp;
vector<int> adjlist[n + 1];
vector<pair<int, pair<int, int>>> v;
for (int i = 1; i <= n; i++) {
adjlist[i].push_back(0);
}
for (int i = 1; i <= t; i++) {
mp[i] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= t; j++) {
int a;
cin >> a;
adjlist[i].push_back(a);
if (a == 0) {
mp[j] = mp[j] + 1;
}
}
}
int modelscore;
int modeltasks;
for (int i = 1; i <= n; i++) {
int score = 0;
int id = i;
int tasks = 0;
for (int j = 1; j <= t; j++) {
if (adjlist[i][j] == 1) {
score = score + mp[j];
tasks++;
}
}
if (i == p) {
modelscore = score;
modeltasks = tasks;
}
v.push_back({score, {tasks, id}});
}
sort(v.begin(), v.end(), greater<pair<int, pair<int, int>>>());
deque<int> rank;
vector<pair<int, int>> tiebkr1;
vector<int> tiebkr2;
for (int i = 0; i < n; i++) {
if (v[i].first > modelscore) {
continue;
} else if (v[i].first < modelscore) {
break;
} else {
tiebkr1.push_back({v[i].second.first, v[i].second.second});
rank.push_back(i);
}
}
if (tiebkr1.size() == 1) {
cout << modelscore << " " << rank[0] + 1;
return 0;
} else {
sort(tiebkr1.begin(), tiebkr1.end(), greater<pair<int, int>>());
for (int i = 0; i < tiebkr1.size(); i++) {
if (tiebkr1[i].first > modeltasks) {
rank.pop_front();
} else if (tiebkr1[i].first < modeltasks) {
break;
} else {
tiebkr2.push_back(tiebkr1[i].second);
}
}
if (tiebkr2.size() == 1) {
cout << modelscore << " " << rank[0] + 1;
} else {
sort(tiebkr2.begin(), tiebkr2.end());
for (int i = 0; i < tiebkr2.size(); i++) {
if (tiebkr2[i] < p) {
rank.pop_front();
} else if (tiebkr2[i] == p) {
cout << modelscore << " " << rank[0] + 1;
break;
}
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |