# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
953354 | DearSimone | Poi (IOI09_poi) | C++17 | 185 ms | 23948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |