Submission #1311199

#TimeUsernameProblemLanguageResultExecution timeMemory
1311199aryanJourney (NOI18_journey)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m,h; cin >> n >> m >> h; vector<vector<pair<int,int>>> adj(n); for(int i = 0;i < n - 1;i++){ for(int j = 0;j < h;j++){ int v,w; cin >> v >> w; if(v <= i) continue; adj[v].push_back(make_pair(i,w)); } } const int inf = 5e8; vector<vector<int>> dp(n,vector<int>(m)); dp[0][0] = 1; // no of ways to reach city i such that sum of weights is j for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ for(pair<int,int> p : adj[i]){ if(dp[i][j] == -1) break; int v = p.first; int w = p.second; if(j - w >= 0){ for(int b = 0;b <= j - w;b++){ if(dp[v][b] == -1){ dp[i][j] = -1; break; } dp[i][j] += dp[v][b]; } } if(dp[i][j] > inf) dp[i][j] = -1; } } } for(int i = 0;i < m;i++){ if(dp[n - 1][i] == -1) cout << inf + 1 << " "; else cout << dp[n - 1][i] << " "; } cout << '\n'; return 0; }#include<bits/stdc++.h> using namespace std; using i64 = long long; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m,h; cin >> n >> m >> h; vector<vector<pair<int,int>>> adj(n); for(int i = 0;i < n - 1;i++){ for(int j = 0;j < h;j++){ int v,w; cin >> v >> w; if(v <= i) continue; adj[v].push_back(make_pair(i,w)); } } const int inf = 5e8; vector<vector<int>> dp(n,vector<int>(m)); dp[0][0] = 1; // no of ways to reach city i such that sum of weights is j for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ for(pair<int,int> p : adj[i]){ if(dp[i][j] == -1) break; int v = p.first; int w = p.second; if(j - w >= 0){ for(int b = 0;b <= j - w;b++){ if(dp[v][b] == -1){ dp[i][j] = -1; break; } dp[i][j] += dp[v][b]; } } if(dp[i][j] > inf) dp[i][j] = -1; } } } for(int i = 0;i < m;i++){ if(dp[n - 1][i] == -1) cout << inf + 1 << " "; else cout << dp[n - 1][i] << " "; } cout << '\n'; return 0; }

Compilation message (stderr)

journey.cpp:53:2: error: stray '#' in program
   53 | }#include<bits/stdc++.h>
      |  ^
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:11: error: 'bits' was not declared in this scope
   53 | }#include<bits/stdc++.h>
      |           ^~~~
journey.cpp:53:16: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
journey.cpp:53:3: error: 'include' does not name a type
   53 | }#include<bits/stdc++.h>
      |   ^~~~~~~
journey.cpp:59:5: error: redefinition of 'int main()'
   59 | int main(){
      |     ^~~~
journey.cpp:7:5: note: 'int main()' previously defined here
    7 | int main(){
      |     ^~~~