QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#248240#7623. Coloring Tapeucup-team1198#Compile Error//C++204.8kb2023-11-11 17:59:192023-11-11 17:59:19

Judging History

你现在查看的是最新测评结果

  • [2023-11-11 17:59:19]
  • 评测
  • [2023-11-11 17:59:19]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

const int MOD = 998244353;

int add(int a, int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}

const int MAXNM = 15 * 510 + 100;
vector<array<int, 2>> cond[MAXNM];
int can[MAXNM];



const int MAXN = 15;

int dp[1 << MAXN][MAXN], dp1[1 << MAXN][MAXN];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    fill(can, can + MAXNM, 1);

    int n, m, cnd;
    cin >> n >> m >> cnd;
    for (int i = 0; i < cnd; ++i) {
        int c, x, y, d;
        cin >> c >> x >> y >> d;
        --c;
        if (d == 0) {
            if (c == 0) {
                cout << "0\n";
                return 0;
            }
            for (int i = x; i < y; ++i) {
                can[c * n + i] = 0;
            }
        } else {
            if (c == 0) {
                continue;
            }
            cond[c].push_back({x, y});
        }
    }

    for (int i = 1; i < m; ++i) {
        sort(cond[i].begin(), cond[i].end(), [](array<int, 2> a, array<int, 2> b) {
            if (a[0] == b[0]) return a[1] > b[1];
            return a[0] < b[0];
        });
        vector<array<int, 2>> seg;
        for (int t = 0; t < (int)cond[i].size(); ++t) {
            bool f = true;
            for (int q = 0; q < (int)cond[i].size(); ++q) {
                if (t == q) continue;
                if (cond[i][q] == cond[i][t] && q < t) {
                    f = false;
                }
                if (cond[i][q] == cond[i][t]) continue;
                if (cond[i][q][0] >= cond[i][t][0] && cond[i][q][1] <= cond[i][t][1]) {
                    f = false;
                }
            }
            if (f) {
                seg.push_back(cond[i][t]);
            }
        }
        cond[i] = seg;
    }

    /// vector<vector<int>> dp((1 << (n + 1)), vector<int>(1, 0));
    dp[(1 << n) - 1][0] = 1;
    int c = 0, r = n - 1;
    int condl = 0, condr = 0;
    for (int i = n - 1; i < n * m - 1; ++i) {
        if (i == 43) {
            /// cerr << "                       DP: " << dp[28][0] << endl;
        }
        /// cerr << "i: " << i << endl;
        ++r;
        if (r == n) {
            r = 0;
            ++c;
            condl = condr = 0;
        }
        while (condl < (int)cond[c].size() && cond[c][condl][1] <= r) ++condl;
        while (condr < (int)cond[c].size() && cond[c][condr][0] <= r) ++condr;
        /// cerr << r << " : " << c << endl;
        /// cerr << "borders: " << condl << " " << condr << endl;
        for (int i = 0; i < (1 << (n + 1)); ++i) {
            fill(dp1[i], dp1[i] + cond[c].size() + 1, 0);
        }
        if (r == 0) {
            for (int mask = 0; mask < (1 << n); ++mask) {
                if (mask & 1) {
                    dp1[mask][0] = add(dp1[mask][0], dp[mask].back());
                }
                dp1[mask | 1 | (1 << n)][0] = add(dp1[mask | 1 | (1 << n)][0], dp[mask].back());
            }
            /// cerr << dp1[(1 << n) - 1][0] << endl;
            for (int i = 0; i < (1 << (n + 1)); ++i) {
                memcpy(dp[i], dp1[i], sizeof(int) * (cond[c].size() + 1));
            }
            continue;
        }
        for (int mask = 0; mask < (1 << n); ++mask) {
            int m1 = mask;
            if (!(mask & (1 << r))) {
                m1 ^= (1 << r);
            }
            for (int i = condl; i <= condr; ++i) {
                if (dp[mask][i] == 0) continue;
                if (mask & (1 << (r - 1))) {
                    dp1[m1 ^ (1 << (r - 1))][i] = add(dp1[m1 ^ (1 << (r - 1))][i], dp[mask][i]);
                }
                if (!can[c * n + r]) continue;
                int j = condr;
                if (mask & (1 << r)) {
                    dp1[m1][j] = add(dp1[m1][j], dp[mask][i]);
                    /// cerr << m1 << " " << j << " " << dp1[m1][j] << endl;
                }
                dp1[m1 + (1 << n)][j] = add(dp1[m1 + (1 << n)][j], dp[mask][i]);
            }
        }
        for (int mask = (1 << n); mask < 2 * (1 << n); ++mask) {
            int m0 = mask;
            if (mask & (1 << r)) {
                m0 ^= (1 << r);
            }
            for (int i = condl; i <= condr; ++i) {
                if (dp[mask][i] == 0) continue;
                dp1[m0][i] = add(dp1[m0][i], dp[mask][i]);
                if (mask & (1 << r)) {
                    dp1[m0 - (1 << n)][i] = add(dp1[m0 - (1 << n)][i], dp[mask][i]);
                }
            }
        }
        for (int i = 0; i < (1 << (n + 1)); ++i) {
            memcpy(dp[i], dp1[i], sizeof(int) * (cond[c].size() + 1));
        }
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        ans = add(ans, dp[mask].back());
    }
    cout << ans << "\n";
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:104:63: error: request for member ‘back’ in ‘dp[mask]’, which is of non-class type ‘int [15]’
  104 |                     dp1[mask][0] = add(dp1[mask][0], dp[mask].back());
      |                                                               ^~~~
answer.code:106:89: error: request for member ‘back’ in ‘dp[mask]’, which is of non-class type ‘int [15]’
  106 |                 dp1[mask | 1 | (1 << n)][0] = add(dp1[mask | 1 | (1 << n)][0], dp[mask].back());
      |                                                                                         ^~~~
answer.code:152:33: error: request for member ‘back’ in ‘dp[mask]’, which is of non-class type ‘int [15]’
  152 |         ans = add(ans, dp[mask].back());
      |                                 ^~~~