답안 #347928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
347928 2021-01-13T19:36:45 Z Alma Poi (IOI09_poi) C++14
0 / 100
689 ms 32620 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);
    for (int i = 0; i < N; i++) {
        int points = 0;
        int solved = 0;
        vector<int> scr (3);
        for (int j = 0; j < 3; 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;

    for (int i = 0; i < N; i++) {
        vector<int> res (T);
        for (int j = 0; j < T; j++) {
            int a; cin >> a;
            res[j] = a;
        }
        results.push_back(res);
    }
    POI (results, N, T, P);
}

Compilation message

poi.cpp: In function 'void POI(std::vector<std::vector<int> >&, int&, int&, int&)':
poi.cpp:48:31: warning: 'P_rank' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     cout << P_score << ' ' << P_rank << endl;
      |                               ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 3 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 6 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 21 ms 1388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 35 ms 2156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 105 ms 5228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 147 ms 7276 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 266 ms 12632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 285 ms 13676 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 422 ms 19716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 470 ms 22380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 636 ms 29368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 689 ms 32620 KB Execution killed with signal 11 (could be triggered by violating memory limits)