답안 #49179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49179 2018-05-23T06:34:51 Z Namnamseo Ice Hockey World Championship (CEOI15_bobek) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define coord_comp(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define v_index(v, x) (lower_bound(all(v),x)-(v).begin())
typedef pair<int,int> pp;
typedef long long ll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ cin>>x; }
template<typename T1,typename T2>
void read(pair<T1,T2>& p){ read(p.first); read(p.second); }
template<typename T,typename... Args>
void read(T&a,Args&...b){ read(a); read(b...); }

ll data[42];

typedef pair<ll,ll> pll;

ll tmp[(1<<20)+5];

vector<pll> work(int dl,int dr){
	int n=dr-dl;
	int am=(1<<n);
	for(int i=0; i<am; ++i){
		ll s=0;
		for(int j=0; j<n; ++j){
			if(1&(i>>j)){
				s += data[dl+j];
			}
		}
		tmp[i]=s;
	}
	sort(tmp, tmp+am);
	vector<pll> ret;
	for(int i=0; i<am;){
		int j;
		for(j=i; j<am && tmp[i]==tmp[j]; ++j);
		ret.pb({tmp[i], j-i});
		i=j;
	}
	return ret;
}

#define BIG

vector<pll> vl, vr;

int main(){
	int n; ll m;
	read(n, m);

	for(int i=0; i<n; ++i){
		ll t;
		read(t);
		data[i]=t;
	}
	int hn = n/2;

	vl=work(0, hn); vr=work(hn, n);

	int sl=sz(vl);
	for(int i=1; i<sl; ++i)
		vl[i].second += vl[i-1].second;

	ll ans=0;
	auto il=vl.begin(), ir=vr.end();
	while(ir != vr.begin()){
		--ir;
		while(il != vl.end()){
			auto it=il; ++it;
			if(it == vl.end()) break;
			if(it->first + ir->first <= m){
				il=it;
			} else break;
		}
		if(il != vl.end() &&
			il->first + ir->first <= m)
			ans += il->second*ir->second;
	}

	printf("%lld\n", ans);

	return 0;
}

Compilation message

bobek.cpp: In function 'std::vector<std::pair<long long int, long long int> > work(int, int)':
bobek.cpp:30:10: error: reference to 'data' is ambiguous
     s += data[dl+j];
          ^~~~
bobek.cpp:17:4: note: candidates are: ll data [42]
 ll data[42];
    ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from bobek.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
bobek.cpp: In function 'int main()':
bobek.cpp:57:3: error: reference to 'data' is ambiguous
   data[i]=t;
   ^~~~
bobek.cpp:17:4: note: candidates are: ll data [42]
 ll data[42];
    ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from bobek.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
bobek.cpp: In function 'void read(int&)':
bobek.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 void read(int& x){ scanf("%d",&x); }
                    ~~~~~^~~~~~~~~