제출 #1268285

#제출 시각아이디문제언어결과실행 시간메모리
1268285ArtTopical (NOI23_topical)C++20
컴파일 에러
0 ms0 KiB
//      - Art -
#include <bits/stdc++.h>

#define el              cout << '\n'

#define FOR(i, a, b)    for (int i = (a), _b = (b); i <= _b; ++i)
#define REV(i, b, a)    for (int i = (b), _a = (a); i >= _a; --i)
#define REP(i, c)       for (int i = 0, _c = (c); i < _c; ++i)

const int N = 1e6 + 7;

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int p[N];

int main() {

    #define name "art"
    if (fopen(name".inp", "r")) {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, k;
    cin >> n >> k;

    vector<vector<int>> a(n, vector<int>(2 * k, 0));
    REP (i, n) REP (j, k) {
        cin >> a[i][j];
    }
    REP (i, n) FOR (j, k, 2 * k - 1) {
        cin >> a[i][j];
    }

    vector<int> perm;
    REP (i, n) {
        perm.emplace_back(i);
    }
    while (clock() / (double)CLOCKS_PER_SEC < 0.98) {
        shuffle(perm.begin(), perm.end(), rng);
        REP (j, k) {
            p[j] = 0;
        }
        ok = true;
        int tmp = 0;
        REP (x, n) {
            int i = perm[x];
            REP (j, k) {
                if (p[j] < a[i][j]) {
                    ok = false; break;
                }
            }
            if (!ok) {
                break;
            }
            FOR (j, k, 2 * k - 1) {
                p[j - k] += a[i][j];
            }
            ++tmp;
        }
        res = max(res, tmp);
    }

    cout << res, el;

    return 0;
}

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

Main.cpp: In function 'int main()':
Main.cpp:49:9: error: 'ok' was not declared in this scope; did you mean 'k'?
   49 |         ok = true;
      |         ^~
      |         k
Main.cpp:66:9: error: 'res' was not declared in this scope
   66 |         res = max(res, tmp);
      |         ^~~
Main.cpp:69:13: error: 'res' was not declared in this scope
   69 |     cout << res, el;
      |             ^~~
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~