제출 #893331

#제출 시각아이디문제언어결과실행 시간메모리
893331KubogiTopical (NOI23_topical)C++17
100 / 100
396 ms166056 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)

const int maxn = 1e6+5;
int n, m, cnt[maxn], p[maxn];
vector<int> a[maxn], u[maxn];
vector<pair<int, int>> val[maxn];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    fileio("");
    // freopen("debug.txt", "w", stderr);

    cin >> n >> m;
    for (int i = 0; i <= n+1; i++) {
        a[i] = vector<int>(m+2, 0);
        u[i] = vector<int>(m+2, 0);
    }

    vector<int> cur;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            if (a[i][j] == 0) {
                cnt[i]++;
            }
            val[j].push_back({a[i][j], i});
        }
        if (cnt[i] == m) {
            cur.push_back(i);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> u[i][j];
        }
    }
    for (int j = 1; j <= m; j++) {
        sort(val[j].rbegin(), val[j].rend());
        while (!val[j].empty() && val[j].back().first == 0) {
            val[j].pop_back();
        }
    }

    int res = 0;
    while (!cur.empty()) {
        int i = cur.back(); cur.pop_back();
        res++;

        for (int j = 1; j <= m; j++) {
            p[j] += u[i][j];
            while (!val[j].empty() && val[j].back().first <= p[j]) {
                int x = val[j].back().second;
                val[j].pop_back();
                if (++cnt[x] == m) {
                    cur.push_back(x);
                }
            }
        }
    }
    cout << res;

    return 0 ^ 0;
}

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

Main.cpp: In function 'int32_t main()':
Main.cpp:5:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:15:5: note: in expansion of macro 'fileio'
   15 |     fileio("");
      |     ^~~~~~
Main.cpp:5:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:15:5: note: in expansion of macro 'fileio'
   15 |     fileio("");
      |     ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...