이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include "aliens.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF 10000000LL
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
ll N,M,K; vector<ll> p;
vector<vector<ll> > dp;
ll f(ll a,ll b)
{
if(dp[a][b]!=-1) {return dp[a][b];}
ll ans=INF;
REP(i,1,a+1)
{
ans=min(ans,((p[a]-p[i]+1LL)*(p[a]-p[i]+1LL))+f(i-1,b-1));
}
ans=min(ans,(p[a]-p[0]+1LL)*(p[a]-p[0]+1LL));
dp[a][b]=ans;
return ans;
}
ll take_photos(int n, int m, int k, vector<int> r, vector<int> c)
{
N=(ll) n; M=(ll) m; K=(ll) k; vector<vector<ll> > oc; vector<ll> xx; REP(i,0,M) {xx.pb(0LL);} REP(i,0,M) {oc.pb(xx);}
if(K==N)
{
ll ans=0;
REP(i,0,N)
{
REP(x,min(r[i],c[i]),max(r[i],c[i])+1LL)
{
REP(y,min(r[i],c[i]),max(r[i],c[i])+1LL)
{
oc[x][y]=1;
}
}
}
REP(i,0,M) {REP(j,0,M) {ans+=oc[i][j];} }
return ans;
}
vector<ll> xxx; REP(i,0,K+1) {xxx.pb(-1);}
REP(i,0,N+1) {dp.pb(xxx);}
dp[0][0]=INF;
REP(i,1,K+1) {dp[0][i]=1LL;}
REP(i,1,N+1) {dp[i][0]=INF;}
REP(i,0,N) {p.pb((ll) r[i]);}
sort(p.begin(),p.end());
return f(N-1,K);
}
컴파일 시 표준 에러 (stderr) 메시지
aliens.cpp: In function 'void Out(std::vector<long long int>)':
aliens.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define REP(i,a,b) for(ll i=a; i<b; i++)
aliens.cpp:24:29:
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
~~~~~~~~~~~~
aliens.cpp:24:25: note: in expansion of macro 'REP'
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |