제출 #848180

#제출 시각아이디문제언어결과실행 시간메모리
848180rukashiiAliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define file if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } #define int long long void setIn(string s) { freopen(s.c_str(),"r",stdin); } void setOut(string s) { freopen(s.c_str(),"w",stdout); } void setIO(string s = "") { if (s.size()) setIn(s+".in"), setOut(s+".out"); } const int maxn = 1002, sz = 502; vector <int> rem; int lf[maxn], rg[maxn], dp[maxn][sz]; pair <int, int> cur[maxn][sz]; int sqr(int p) { return p * p; } int area(int l, int r) { return sqr(r - l + 1); } long long take_photos(int n, int m, int k, vector <int> r, vector <int> c) { //square n x n //picture <= m swap(n, m); memset(dp, 0x3f3f3f3f, sizeof(dp)); memset(lf, 0x3f3f3f3f, sizeof(lf)); memset(rg, -0x3f3f3f3f, sizeof(rg)); for (int i = 0; i < m; i++) { rem.push_back(r[i]); lf[r[i]] = min(lf[r[i]], c[i]); rg[r[i]] = max(rg[r[i]], c[i]); } sort(rem.begin(), rem.end()); rem.erase(unique(rem.begin(), rem.end()), rem.end()); sort(rem.begin(), rem.end()); // cout << rem.size() << '\n'; // for (int i = 0; i < rem.size(); i++) // cout << lf[rem[i]] << ' ' << rg[rem[i]] << '\n'; dp[0][1] = area(min(lf[rem[0]], rem[0]), max(rem[0], rg[rem[0]])); cur[0][1] = {min(lf[rem[0]], rem[0]), max(rem[0], rg[rem[0]])}; for (int i = 1; i < rem.size(); i++) { for (int t = 0; t < i; t++) { for (int j = 1; j <= k; j++) { if (dp[t][j - 1] + area(min(lf[rem[i]], rem[i]), max(rem[i], rg[rem[i]])) < dp[i][j]) { dp[i][j] = dp[t][j - 1] + area( min(lf[rem[i]], rem[i]), max(rem[i], rg[rem[i]]) ) ; cur[i][j] = {min(lf[rem[i]], rem[i]), max(rg[rem[i]], rem[i])}; } auto [ll, rr] = cur[t][j]; int new_area = max(sqr(rem[i] - rem[t] + 1), area(min({rem[t], ll, lf[rem[i]]}), max({rr, rg[rem[i]], rem[i]}))); int old_area = sqr(rr - ll + 1); if (dp[t][j] - old_area + new_area < dp[i][j]) { dp[i][j] = dp[t][j] - old_area + new_area; cur[i][j] = {min({rem[t], ll, lf[rem[i]]}), max({rr, rg[rem[i]], rem[i]})}; } } } } // cout << dp[rem.size() - 1][k] << '\n'; // for (int i = 0; i < rem.size(); i++) int ans = 0x3f3f3f3f; for (int j = 1; j <= k; j++) ans = min(ans, dp[rem.size() - 1][j]); return ans; // cout << cur[1][k].first << ' ' << cur[1][k].second; } // signed main() // { // // setIO(); // file; // ios::sync_with_stdio(0); cin.tie(0); // // take_photos(2, 6, 2, {1, 4}, {4, 1}); // take_photos(5, 7, 2, {0, 4, 4, 4, 4}, {3, 4, 6, 5, 6}); // }

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

aliens.cpp: In function 'long long int take_photos(long long int, long long int, long long int, std::vector<long long int>, std::vector<long long int>)':
aliens.cpp:54:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 1; i < rem.size(); i++)
      |                     ~~^~~~~~~~~~~~
aliens.cpp: In function 'void setIn(std::string)':
aliens.cpp:8:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | void setIn(string s) { freopen(s.c_str(),"r",stdin); }
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
aliens.cpp: In function 'void setOut(std::string)':
aliens.cpp:9:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | void setOut(string s) { freopen(s.c_str(),"w",stdout); }
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccE02K7C.o: in function `main':
grader.cpp:(.text.startup+0xf0): undefined reference to `take_photos(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status