답안 #348773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
348773 2021-01-15T16:35:09 Z Alma Poi (IOI09_poi) C++14
컴파일 오류
0 ms 0 KB
#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 = 0;
    // 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;
        }
        results.push_back(res);
    }
    POI (results, N, T, P);
}

Compilation message

poi.cpp: In function 'int main()':
poi.cpp:59:27: error: 'res' was not declared in this scope
   59 |         results.push_back(res);
      |                           ^~~