답안 #1013984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013984 2024-07-04T09:09:32 Z Ariadna Topical (NOI23_topical) C++14
100 / 100
632 ms 142000 KB
#include <bits/stdc++.h>
#define pb push_back

using namespace std;


int n, k;
vector<vector<int>> r, u;

int modules() {
    queue<int> q;
    int cnt = 0;
    vector<vector<pair<int, int>>> m(k);
    vector<int> knowledge(k), completed(k);
    vector<int> m_completed(n, 0), visited(n, 0);
    for (int i = 0; i < n; ++i) {
        bool done = 1;
        for (int j = 0; j < k; ++j) {
            if (r[i][j] > 0) done = 0;
            m[j].pb({r[i][j], i});
        }
        if (done) {
            q.push(i);
            visited[i] = true;
        }
    }

    if (q.empty()) return 0;

    for (int i = 0; i < k; ++i) sort(m[i].begin(), m[i].end());
    while (!q.empty()) {
        int mod = q.front();
        q.pop();
        ++cnt;
        for (int i = 0; i < k; ++i) {
            knowledge[i] += u[mod][i];

            while (completed[i] < n && m[i][completed[i]].first <= knowledge[i]) {
                if (++m_completed[m[i][completed[i]].second] == k && !visited[m[i][completed[i]].second]) {
                    q.push(m[i][completed[i]].second);
                    visited[m[i][completed[i]].second] = true;
                }
                ++completed[i];
            }
        }
    }

    return cnt;
}

int main() {
    cin >> n >> k;
    r = u = vector<vector<int>>(n, vector<int>(k));

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < k; ++j) {
            cin >> r[i][j];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < k; ++j) {
            cin >> u[i][j];
        }
    }

    cout << modules() << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 1180 KB Output is correct
4 Correct 403 ms 82440 KB Output is correct
5 Correct 346 ms 82504 KB Output is correct
6 Correct 385 ms 82484 KB Output is correct
7 Correct 234 ms 76592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 5 ms 700 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 4 ms 604 KB Output is correct
10 Correct 5 ms 604 KB Output is correct
11 Correct 5 ms 696 KB Output is correct
12 Correct 5 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 6 ms 1884 KB Output is correct
4 Correct 56 ms 14768 KB Output is correct
5 Correct 55 ms 14536 KB Output is correct
6 Correct 621 ms 142000 KB Output is correct
7 Correct 619 ms 139572 KB Output is correct
8 Correct 632 ms 141892 KB Output is correct
9 Correct 582 ms 139460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 1180 KB Output is correct
4 Correct 403 ms 82440 KB Output is correct
5 Correct 346 ms 82504 KB Output is correct
6 Correct 385 ms 82484 KB Output is correct
7 Correct 234 ms 76592 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 5 ms 700 KB Output is correct
15 Correct 5 ms 860 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 5 ms 696 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 6 ms 1884 KB Output is correct
23 Correct 56 ms 14768 KB Output is correct
24 Correct 55 ms 14536 KB Output is correct
25 Correct 621 ms 142000 KB Output is correct
26 Correct 619 ms 139572 KB Output is correct
27 Correct 632 ms 141892 KB Output is correct
28 Correct 582 ms 139460 KB Output is correct
29 Correct 482 ms 36812 KB Output is correct
30 Correct 420 ms 33768 KB Output is correct
31 Correct 440 ms 38592 KB Output is correct
32 Correct 369 ms 27472 KB Output is correct
33 Correct 330 ms 26452 KB Output is correct
34 Correct 382 ms 29500 KB Output is correct
35 Correct 393 ms 35056 KB Output is correct
36 Correct 367 ms 32704 KB Output is correct
37 Correct 440 ms 35388 KB Output is correct
38 Correct 214 ms 27336 KB Output is correct