Submission #1160367

#TimeUsernameProblemLanguageResultExecution timeMemory
1160367InvMODHoliday (IOI14_holiday)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define name "InvMOD" #ifndef name #include "holiday.h" #endif // name using namespace std; #define all(v) (v).begin(), (v).end() using ll = long long; template<typename T> bool ckmx(T& a, const T& b){ if(a < b) return a = b, true; return false; } const int N = 1e5 + 5; const ll INF = 1e15; ll findMaxAttraction(int n, int start, int d, int attraction[]){ start = start + 1; vector<int> a(n + 1); for(int i = 1; i <= n; i++){ a[i] = attraction[i - 1]; } ll answer = 0; auto calc_dp = [&]() -> void{ vector<vector<vector<ll>>> dp_Up(2, vector<vector<ll>>(d + 1, vector<ll>(n + 1, -INF))); vector<vector<vector<ll>>> pdp_Up(2, vector<vector<ll>>(d + 1, vector<ll>(n + 1, -INF))); dp_Up[0][0][start] = pdp_Up[0][0][start] = 0; for(int day = 1; day <= d; day++){ for(int i = start; i <= n; i++){ if(dp_Up[0][(day - 1) & 1][i] != -INF) dp_Up[1][(day & 1)][i] = dp_Up[0][(day - 1) & 1][i] + a[i]; if(i > 1) ckmx(dp_Up[0][(day & 1)][i], dp_Up[0][(day - 1) & 1][i - 1]); if(i > 1) ckmx(dp_Up[0][(day & 1)][i], dp_Up[1][(day - 1) & 1][i - 1]); } pdp_Up[0][(day & 1)] = dp_Up[0][(day & 1)]; pdp_Up[1][(day & 1)] = dp_Up[1][(day & 1)]; for(int i = n - 1; i >= start; i--){ ckmx(pdp_Up[0][(day & 1)][i], pdp_Up[0][(day - 1) & 1][i + 1]); ckmx(pdp_Up[1][(day & 1)][i], pdp_Up[1][(day - 1) & 1][i + 1]); } for(int i = start - 1; i >= 1; i--){ if(pdp_Up[0][(day - 1) & 1][i] != -INF) pdp_Up[1][(day & 1)][i] = pdp_Up[0][(day - 1) & 1][i] + a[i]; if(i < n) ckmx(pdp_Up[0][(day & 1)][i], pdp_Up[0][(day - 1) & 1][i + 1]); if(i < n) ckmx(pdp_Up[0][(day & 1)][i], pdp_Up[1][(day - 1) & 1][i + 1]); } for(int i = 1; i <= n; i++){ ckmx(answer, pdp_Up[0][(day & 1)][i]); ckmx(answer, pdp_Up[1][(day & 1)][i]); } } }; calc_dp(); reverse(1 + all(a)); start = n - start + 1; calc_dp(); return answer; } #ifdef name int32_t main(){ if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } int n,start,d; cin >> n >> start >> d; int attraction[n]; for(int i = 0; i < n; i++){ cin >> attraction[i]; } cout << findMaxAttraction(n, start, d, attraction) << "\n"; return 0; } #endif // name

Compilation message (stderr)

holiday.cpp: In function 'int32_t main()':
holiday.cpp:78:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |             freopen(name".INP", "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
holiday.cpp:79:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |             freopen(name".OUT", "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccAeKYsI.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccI3yRLh.o:holiday.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status