Submission #1082328

# Submission time Handle Problem Language Result Execution time Memory
1082328 2024-08-31T07:20:11 Z Whisper Journey (NOI18_journey) C++17
69 / 100
2000 ms 48460 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define REPD(i, a) for (int i = (a) - 1; i >= 0; --i)

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)


constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
    Phu Trong from Nguyen Tat Thanh High School for gifted student
*/

template <class X, class Y>
    bool minimize(X &x, const Y &y){
        X eps = 1e-9;
        if (x > y + eps) {x = y; return 1;}
        return 0;
    }

template <class X, class Y>
    bool maximize(X &x, const Y &y){
        X eps = 1e-9;
        if (x + eps < y) {x = y; return 1;}
        return 0;
    }
int numCity, maxNight, numFlight;

#define MAX_CITY                    10005
#define MAX_NIGHT                   404
#define MAX_FLIGHT                  101

pair<int, int> A[MAX_CITY][MAX_FLIGHT];


const int oo = 5e8 + 1;


namespace SUBTASK_3{
    int dp[MAX_CITY][MAX_NIGHT];
    bool check(void){
        return numCity <= 100 && maxNight <= 100 && numFlight <= 100;
    }

    void main(void){
        dp[1][0] = 1;
        for (int cur = 1; cur < numCity; ++cur){
            for (int night = 0; night <= maxNight; ++night){
                for (int i = 1; i <= numFlight; ++i){
                    int next = A[cur][i].first, least = A[cur][i].second;
                    if(next <= cur) continue;
                    for (int j = least; j + night <= maxNight; ++j){
                        dp[next][j + night] += dp[cur][night];
                        minimize(dp[next][j + night], oo);
                    }
                }
            }
        }
        for (int i = 0; i <= maxNight; ++i){
            cout << dp[numCity][i] << " ";
        }
    }
}
void process(void){
    cin >> numCity >> maxNight >> numFlight;
    --maxNight;
    for (int i = 1; i < numCity; ++i){
        for (int j = 1; j <= numFlight; ++j){
            cin >> A[i][j].first >> A[i][j].second;
            ++A[i][j].first;
        }
    }

//    if(SUBTASK_3 :: check()) {
        SUBTASK_3 :: main();
//        return;
//    }
}
signed main(){
    #define name "Whisper"
    cin.tie(nullptr) -> sync_with_stdio(false);
    //freopen(name".inp", "r", stdin);
    //freopen(name".out", "w", stdout);
    process();
    return (0 ^ 0);
}




# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 11 ms 2652 KB Output is correct
6 Correct 8 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 11 ms 2652 KB Output is correct
6 Correct 8 ms 2648 KB Output is correct
7 Correct 112 ms 48460 KB Output is correct
8 Correct 387 ms 30144 KB Output is correct
9 Correct 494 ms 5104 KB Output is correct
10 Execution timed out 2045 ms 5460 KB Time limit exceeded
11 Halted 0 ms 0 KB -