Submission #379918

# Submission time Handle Problem Language Result Execution time Memory
379918 2021-03-19T16:57:36 Z rocks03 Journey (NOI18_journey) C++14
20 / 100
1 ms 620 KB
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 1e4+100;
const int MAXM = 4e2+100;
const ll MAX = 5e8+1;
int N, M, H;
vector<pii> g[MAXN];
ll dp[MAXM][MAXN];

void solve(){
    cin >> N >> M >> H;
    rep(i, 0, N - 1){
        rep(h, 0, H){
            int j, w;
            cin >> j >> w;
            g[i].pb({j, w});
        }
    }
    dp[0][0] = 1;
    rep(v, 0, N - 1){
        rep(m, 0, M){
            dp[m + 1][v] += dp[m][v];
        }
        for(auto [u, w] : g[v]){
            per(m, M, w){
                dp[m][u] = min(MAX, dp[m][u] + dp[m - w][v]);
            }
        }
    }
    rep(m, 0, M){
        cout << dp[m][N - 1] << " ";
    }
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    solve();
    return 0;
}

Compilation message

journey.cpp: In function 'void solve()':
journey.cpp:41:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |         for(auto [u, w] : g[v]){
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Incorrect 1 ms 620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Incorrect 1 ms 620 KB Output isn't correct
4 Halted 0 ms 0 KB -