제출 #124847

#제출 시각아이디문제언어결과실행 시간메모리
124847nvmdavaAliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int> > v, t;

long long dp[505][505];

long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
	memset(temp, -1, sizeof temp);
	
    for(int i = 0; i < n; i++)
    	t.push_back({min(r[i], c[i]), max(c[i], r[i]) + 1});
	sort(t.begin(), t.end());
	int mx = -1;
	v.push_back({-1, -1});
	for(auto& x : t)
		if(x.second > mx)
			v.push_back({x.first, mx = x.second});
	
	n = v.size() - 1;
	k = min(k, n);
	
	memset(dp, 0x3f3f, sizeof dp);
	dp[0][0] = 0;
	
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= n; j++){
			dp[i][j] = dp[i - 1][j];
			for(int l = 0; l < j; l++){
				dp[i][j] = min(dp[i][j], dp[i - 1][l] + (v[j].second - v[l + 1].first) * (v[j].second - v[l + 1].first));
			}
		}
	}
	return dp[k][n];
}

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

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:10:9: error: 'temp' was not declared in this scope
  memset(temp, -1, sizeof temp);
         ^~~~
aliens.cpp:10:9: note: suggested alternative: 'time'
  memset(temp, -1, sizeof temp);
         ^~~~
         time
aliens.cpp:12:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i = 0; i < n; i++)
     ^~~
aliens.cpp:14:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  sort(t.begin(), t.end());
  ^~~~