Submission #894611

#TimeUsernameProblemLanguageResultExecution timeMemory
894611IWKRPoi (IOI09_poi)C++17
100 / 100
757 ms24504 KiB
#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)

poi.cpp: In function 'int main()':
poi.cpp:63:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for (int i = 0; i < tiebkr1.size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~~
poi.cpp:76:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |    for (int i = 0; i < tiebkr2.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~
poi.cpp:66:11: warning: 'modeltasks' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |    } else if (tiebkr1[i].first < modeltasks) {
      |           ^~
poi.cpp:51:10: warning: 'modelscore' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |   } else if (v[i].first < modelscore) {
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...