Submission #1082328

#TimeUsernameProblemLanguageResultExecution timeMemory
1082328WhisperJourney (NOI18_journey)C++17
69 / 100
2045 ms48460 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...