秋祭 | 静岡高校工学部



卬高杯


提出詳細

提出id提出時刻ユーザー名問題言語判定状況判定実行時間
1149062023-10-24 12:39:20U_SIcpp25/25TLE2001

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int mod = 127237991;

int n;
vector<vector<int>> a(5);
vector<vector<long long>> memo(5, vector<long long>(1000, 1));
vector<vector<bool>> visit(5, vector<bool>(1000, false));

long long f(int x, int y) {
    if (visit[x][y]) return memo[x][y];
    if (x == 4) return 1;
    int m = upper_bound(a[x + 1].begin(), a[x + 1].end(), a[x][y]) - a[x + 1].begin();
    if (m == n) return 0;
    long long cnt = 0;
    for (int i = m; i < n; i++) {
        cnt += f(x + 1, i);
        cnt %= mod;
    }
    memo[x][y] = cnt;
    visit[x][y] = true;
    return memo[x][y];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n;
    for (int i = 0; i < 5; i++) {
        a[i].resize(n);
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
        sort(a[i].begin(), a[i].end());
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += f(0, i) % mod;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}
C++

sample1.txt AC 2
sample2.txt AC 2
sample3.txt AC 7
sample4.txt AC 3
sample5.txt AC 6
case1.txt AC 8
case2.txt AC 6
case3.txt AC 7
case4.txt AC 9
case5.txt AC 7
case6.txt TLE 192
case7.txt TLE 151
case8.txt TLE 166
case9.txt TLE 2001
case10.txt TLE 2001
case11.txt TLE 225
case12.txt TLE 263
case13.txt TLE 213
case14.txt TLE 246
case15.txt TLE 233
case16.txt TLE 182
case17.txt TLE 262
case18.txt TLE 181
case19.txt TLE 243
case20.txt TLE 180
2001 RE2001 TLE
timeout: the monitored command dumped core
Segmentation fault