Submission #714075

#TimeUsernameProblemLanguageResultExecution timeMemory
714075mseebacherBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms2644 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; #define MAXI (int)1e5 #define pb(x) push_back(x) vector<int> ad[MAXI]; vector<bool> vis(MAXI,0); void dfs(int x){ if(vis[x]) return; vis[x] = 1; for(auto s:ad[x]){ dfs(s); } } void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } ll pref(int n,int k,int l,int pos[],int pre){ ll ans = 0; for(int i = k-1;i<pre;i+=k){ ans += pos[i] + min(pos[i],l-pos[i]); } if(pre%k != 0)ans += pos[pre-1] + min(pos[pre-1],l-pos[pre-1]); cout << ans << " "; return ans; } ll suff(int n,int k,int l,int pos[],int pre){ ll ans = 0; for(int i = n-k;i>=pre;i-=k){ ans += (l-pos[i]) + min(pos[i],l-pos[i]); } if((n-pre)%k != 0)ans += l-pos[pre] + min(pos[pre],l-pos[pre]); cout << ans << " "; return ans; } ll delivery(int n,int k,int l,int pos[]){ ll ans = 1e18; for(int i = 0;i<=n;i++){ ans = min(ans,pref(n,k,l,pos,i)+suff(n,k,l,pos,i)); cout << "\n"; } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll pref(int, int, int, int*, int)':
boxes.cpp:27:13: warning: unused parameter 'n' [-Wunused-parameter]
   27 | ll pref(int n,int k,int l,int pos[],int pre){
      |         ~~~~^
boxes.cpp: In function 'void setIO(std::string)':
boxes.cpp:22:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:23:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  freopen((s + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...