제출 #348778

#제출 시각아이디문제언어결과실행 시간메모리
348778AlmaPoi (IOI09_poi)C++14
70 / 100
715 ms16236 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; void POI (vector<vector<int>>& results, int& N, int& T, int& P) { vector<int> value; value.assign(T, 0); // value of each problem for (int i = 0; i < N; i++) { for (int j = 0; j < T; j++) { if (results[i][j] == 0) { value[j]++; } } } // scores: points-solved-ID vector<vector<int>> scores (N, vector<int> (3)); for (int i = 0; i < N; i++) { int points = 0; int solved = 0; for (int j = 0; j < T; j++) { if (results[i][j] == 1) { points += value[j]; solved++; } } scores[i][0] = points; scores[i][1] = solved; scores[i][2] = i+1; } // Philip: int P_score = scores[P-1][0]; int P_solved = scores[P-1][1]; int P_rank; // Philip rank sort(scores.rbegin(), scores.rend()); for (int i = 0; i < N; i++) { if (scores[i][0] == P_score) { if (scores[i][1] == P_solved) { if (scores[i][2] == P) { P_rank = i+1; }}} } cout << P_score << ' ' << P_rank << endl; } int main () { int N, T, P; cin >> N >> T >> P; vector<vector<int>> results (N, vector<int> (T)); for (int i = 0; i < N; i++) { for (int j = 0; j < T; j++) { int a; cin >> a; results[i][j] = a; } } POI (results, N, T, P); }

컴파일 시 표준 에러 (stderr) 메시지

poi.cpp: In function 'void POI(std::vector<std::vector<int> >&, int&, int&, int&)':
poi.cpp:47:31: warning: 'P_rank' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     cout << P_score << ' ' << P_rank << endl;
      |                               ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...