제출 #169107

#제출 시각아이디문제언어결과실행 시간메모리
169107mohammad_kilaniAliens (IOI16_aliens)C++17
4 / 100
2 ms632 KiB
#include <bits/stdc++.h> #include "aliens.h" using namespace std; const int N = 4010 , K = 4010; vector< pair<int,int> > arr , tmp; long long dp[N][K]; int n , m , k; long long a[N] , b[N] , c[N] , tmpb[N]; long long tmp1 , g; inline long long get(long long a1,long long b1,long long a2,long long b2){ if(b1 == b2) return -(long long)1e18; tmp1 = (a1 - a2) / (b2 - b1) - (((a2 - a2) < 0) ^ ((b2 - b1) < 0) ? 1 : 0); return tmp1; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){ for(int i = 0 ;i < n;i++){ arr.push_back(make_pair(min(r[i] , c[i]) , -max(r[i] , c[i]))); } sort(arr.begin(),arr.end()); int mx = -1; for(int i = 0 ;i < (int)arr.size();i++){ arr[i].second = -arr[i].second; if(arr[i].second > mx){ tmp.push_back(arr[i]); mx = arr[i].second; } } arr = tmp; n = (int)arr.size(); ::n = n; ::m = m; ::k = k; for(int i = 0 ;i < n;i++){ b[i] = (long long)(arr[i].second + 1) * (long long)(arr[i].second + 1); if(i < n - 1 && arr[i].second >= arr[i + 1].first) b[i] -= (long long)(arr[i].second - arr[i + 1].first + 1) * (long long)(arr[i].second - arr[i + 1].first + 1); a[i] = -2 * (long long)(arr[i].second + 1); c[i] = (long long)arr[i].first * (long long)arr[i].first; } for(int i = 0 ;i < n;i++){ dp[i][k] = (long long)1e18; } pair<int,int> tmp; for(int j = k - 1;j >= 0;j--){ deque < pair<long long,int> > q; for(int i = n - 1;i >= 0 ;i--){ tmpb[i] = dp[i + 1][j + 1] + b[i]; dp[i][j] = c[i] + a[i] * (long long)arr[i].first + tmpb[i]; while((int)q.size() > 1){ tmp = q.back(); q.pop_back(); if(q.back().first < (long long)arr[i].first){ q.push_back(tmp); break; } } if((int)q.size() > 0){ tmp = q.back(); dp[i][j] = min(dp[i][j] , c[i] + a[tmp.second] * (long long)arr[i].first + tmpb[tmp.second]); } while((int)q.size() > 0){ g = get(a[i] , tmpb[i] , a[q.front().second] , tmpb[q.front().second]); if(g >= q.front().first){ q.pop_front(); continue; } break; } if((int)q.size() == 0) g = (long long)1e18; else g = get(a[i] , tmpb[i] , a[q.front().second] , tmpb[q.front().second]); q.push_front(make_pair(g , i)); } } return dp[0][0]; }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:41:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(i < n - 1 && arr[i].second >= arr[i + 1].first)
   ^~
aliens.cpp:43:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    a[i] = -2 * (long long)(arr[i].second + 1);
    ^
#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...