Submission #1043897

#TimeUsernameProblemLanguageResultExecution timeMemory
1043897vjudge1Paprike (COI18_paprike)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 1; vector<int> nei[M]; int cts[M],sps[M],k; void dfs(int u,int p=0) { vector<int> v; for (int i:nei[u]) if (i!=p) { dfs(i,u); cts[u]+=cts[i]; sps[u]+=sps[i]; v.push_back(sps[i]); } sort(v.begin(),v.end()); while (sps[u]>k) { sps[u]-=v.back(); cts[u]++; } } int main() { int n; cin>>n>>k; int a[n]; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<n;i++) { int u,v; cin>>u>>v; nei[u].push_back(v); nei[v].push_back(u); } int ans=n-1; for (int i=1;i<=n;i++) { for (int j=1;j<=n;j++)#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 1; vector<int> nei[M]; int cts[M],sps[M],k; void dfs(int u,int p=0) { vector<int> v; for (int i:nei[u]) if (i!=p) { dfs(i,u); cts[u]+=cts[i]; sps[u]+=sps[i]; v.push_back(sps[i]); } sort(v.begin(),v.end()); while (sps[u]>k) { sps[u]-=v.back(); cts[u]++; } } int main() { int n; cin>>n>>k; int a[n]; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<n;i++) { int u,v; cin>>u>>v; nei[u].push_back(v); nei[v].push_back(u); } int ans=n-1; for (int i=1;i<=n;i++) { for (int j=1;j<=n;j++) sps[j]=a[j],cts[j]=0; dfs(i); ans=min(ans,cts[i]); } cout<<ans<<endl; return 0; } sps[j]=a[j],cts[j]=0; dfs(i); ans=min(ans,cts[i]); } cout<<ans<<endl; return 0; }

Compilation message (stderr)

paprike.cpp:46:25: error: stray '#' in program
   46 |   for (int j=1;j<=n;j++)#include <bits/stdc++.h>
      |                         ^
paprike.cpp: In function 'int main()':
paprike.cpp:46:26: error: 'include' was not declared in this scope
   46 |   for (int j=1;j<=n;j++)#include <bits/stdc++.h>
      |                          ^~~~~~~
paprike.cpp:46:35: error: 'bits' was not declared in this scope
   46 |   for (int j=1;j<=n;j++)#include <bits/stdc++.h>
      |                                   ^~~~
paprike.cpp:46:40: error: 'stdc' was not declared in this scope; did you mean 'std'?
   46 |   for (int j=1;j<=n;j++)#include <bits/stdc++.h>
      |                                        ^~~~
      |                                        std
paprike.cpp:48:1: error: expected primary-expression before 'using'
   48 | using namespace std;
      | ^~~~~
paprike.cpp:56:1: error: a function-definition is not allowed here before '{' token
   56 | {
      | ^
paprike.cpp:75:1: error: a function-definition is not allowed here before '{' token
   75 | {
      | ^
paprike.cpp:100:8: error: 'j' was not declared in this scope
  100 |    sps[j]=a[j],cts[j]=0;
      |        ^
paprike.cpp:53:19: warning: unused variable 'k' [-Wunused-variable]
   53 | int cts[M],sps[M],k;
      |                   ^