제출 #934778

#제출 시각아이디문제언어결과실행 시간메모리
934778Edu175Aliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include "aliens.h"
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(ll i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define imp(v) for(auto messi:v)cout<<messi<<" "; cout<<"\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll INF=2e12;
ll sq(ll n){return n*n;}
vector<ii>a;
ll cost(ll i, ll j){
	ll res=sq(a[j].snd-a[i].fst);
	if(i&&a[i-1].snd>a[i].fst)res-=sq(a[i-1].snd-a[i].fst);
	return res;
}
const ll MAXN=1e5+5;
__int128 dp[MAXN];
cnt[MAXN];
void dnc(ll l, ll r, ll s, ll e, ll d){
	if(r-l<=0)return;
	ll m=(l+r)/2,mn=m,&res=dp[m];
	res=INF;
	fore(x,max(s,m),e){
		ll resi=cost(m,x)+d+dp[x+1];
		if(resi<res)mn=x,res=resi,cnt[m]=cnt[x+1]+1;
	}
	//cout<<"["<<l<<","<<r<<") "<<m<<","<<c<<" ["<<s<<","<<e<<"): "<<res<<" ("<<mn<<")\n";
	if(r-l>1){
		dnc(l,m,s,mn+1,d),dnc(m+1,r,mn,e,d);
	}
}

long long take_photos(int n, int m, int k, std::vector<int> R, std::vector<int> C) {
	vector<ii>a_;
	fore(i,0,n){
		ll l=R[i],r=C[i];
		if(l>r)swap(l,r);
		r++;
		a.pb({l,-r});
	}
	sort(ALL(a));
	//for(auto i:a)cout<<i.fst<<","<<i.snd<<" ";;cout<<"\n";;
	ll r=0;
	for(auto [s,e]:a){
		e=-e;
		if(e>r)a_.pb({s,e}),r=e;
	}
	a=a_;
	n=SZ(a);
	//for(auto i:a)cout<<i.fst<<","<<i.snd<<" ";;cout<<"\n";
	ll l=-1e13; r=1e13;
	while(l<=r){
		ll m=(l+r)/2;
		dnc(0,n,0,n,m);
		if(cnt[0]<=k)r=m-1;
		else l=m+1;
	}
	dnc(0,n,0,n,l);
	return __int128(dp[0])-__int128(l)*cnt[0];
}

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

aliens.cpp:25:1: error: 'cnt' does not name a type; did you mean 'int'?
   25 | cnt[MAXN];
      | ^~~
      | int
aliens.cpp: In function 'void dnc(ll, ll, ll, ll, ll)':
aliens.cpp:28:29: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to an rvalue of type 'll' {aka 'long long int'}
   28 |  ll m=(l+r)/2,mn=m,&res=dp[m];
      |                         ~~~~^
aliens.cpp:32:29: error: 'cnt' was not declared in this scope; did you mean 'int'?
   32 |   if(resi<res)mn=x,res=resi,cnt[m]=cnt[x+1]+1;
      |                             ^~~
      |                             int
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:62:6: error: 'cnt' was not declared in this scope; did you mean 'int'?
   62 |   if(cnt[0]<=k)r=m-1;
      |      ^~~
      |      int
aliens.cpp:66:37: error: 'cnt' was not declared in this scope; did you mean 'int'?
   66 |  return __int128(dp[0])-__int128(l)*cnt[0];
      |                                     ^~~
      |                                     int