Submission #1102824

#TimeUsernameProblemLanguageResultExecution timeMemory
1102824blackslexTopical (NOI23_topical)C++17
40 / 100
1069 ms161396 KiB
#include<bits/stdc++.h>

using namespace std;
using pii = pair<int, int>;

int n, k;

int main() {
    scanf("%d %d", &n, &k);
    vector<vector<int>> r(n + 5, vector<int>(k + 5)), u(n + 5, vector<int>(k + 5));
    vector<int> p(k + 5), done(n + 5);
    vector<multiset<pii>> ms(k + 5);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            scanf("%d", &r[i][j]);
            if (r[i][j]) ms[j].emplace(r[i][j], i);
            else done[i]++;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) scanf("%d", &u[i][j]);
    }
    queue<int> q;
    vector<bool> f(n + 5);
    for (int i = 1; i <= n; i++) if (done[i] == k) q.emplace(i);
    while (!q.empty()) {
        int cur = q.front(); q.pop();
        if (f[cur]) continue; f[cur] = 1;
        for (int j = 1; j <= k; j++) {
            p[j] += u[cur][j];
            while (!ms[j].empty() && ms[j].begin()->first <= p[j]) {
                int i = ms[j].begin()->second;
                done[i]++;
                if (done[i] == k) q.emplace(i);
                ms[j].erase(ms[j].begin());
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) if (f[i]) ans++;
    printf("%d", ans);
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |         if (f[cur]) continue; f[cur] = 1;
      |         ^~
Main.cpp:28:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |         if (f[cur]) continue; f[cur] = 1;
      |                               ^
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d", &r[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:21:43: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         for (int j = 1; j <= k; j++) scanf("%d", &u[i][j]);
      |                                      ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...