제출 #555684

#제출 시각아이디문제언어결과실행 시간메모리
555684FidanAliens (IOI16_aliens)C++17
0 / 100
1 ms340 KiB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
long long take_photos(ll n, ll m, ll k, vector<ll> r, vector<ll> c) {
	vector<bool> v(m+1, false);
	ll i, j, h;
	for(i=0; i<n; i++){
		r[i]++;
		v[r[i]]=true;
	}
	vector<vector<ll>> dp(m+1, vector<ll> (k+1, n*n+100));
	for(i=0; i<=m; i++){
		if(v[i]) {
			h=i;
			break;
		}
	}
	for(i=0; i<h; i++){
		for(j=0; j<=k; j++){
			dp[i][j]=0;
		}
	}
	for(i=h; i<=m; i++){
		if(!v[i]){
			dp[i][1]=dp[i-1][1];
		}
		else {
			dp[i][1]=(i-h+1)*(i-h+1);
		}
	}
	for(i=1; i<=m; i++){
		for(j=1; j<=k; j++){
			if(!v[i]){
				dp[i][j]=dp[i-1][j];
			}
			else {
				dp[i][j]=min(dp[i][j], dp[i][j-1]);
				for(ll a: r){
					if(a>i){
						break;
					}
					dp[i][j]=min(dp[i][j], dp[a-1][j-1]+(i-a+1)*(i-a+1));
				}
			}
		}
	}
	
	return dp[n][k];
}

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

aliens.cpp: In function 'long long int take_photos(ll, ll, ll, std::vector<int>, std::vector<int>)':
aliens.cpp:25:10: warning: 'h' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   if(!v[i]){
      |          ^
#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...