답안 #20509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20509 2017-02-12T07:21:10 Z 안녕하세요 투어리스트입니다 진짜에요(#49, Namnamseo) 복불복 (OJUZ11_luck) C++
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back

int n, k;
int a[1010];
int b[1010];
const ll M=int(1e9)+7;

void in(){
	read(n, k);
    for(int i=1; i<=n; ++i) read(a[i]); sort(a+1, a+n+1, greater<int>());
    for(int i=1; i<=n; ++i) read(b[i]); sort(b+1, b+n+1);
}

void naive(){
	int ind[1010];
    for(int i=1; i<=n; ++i) ind[i]=i;
	int ans=0;
	int c[1010];
	do {
		for(int i=1; i<=n; ++i) c[i]=a[i]+b[ind[i]];
		bool flg=1;
		int max_rnk = 0;
		for(int i=1; i<=k; ++i){
			int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
			max_rnk = max(max_rnk, rnk);
			if(rnk > k)
				flg=0;
		}
		for(int i=k+1; i<=n; ++i){
			int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
			if(rnk < max_rnk)
				flg=0;
		}
		ans += flg;
	} while(next_permutation(ind+1, ind+n+1));
	printf("%d\n", ans);
}

int main()
{
#ifdef NAMSEO
	freopen("in", "r", stdin);
#endif
    in();
    if(n<=8) naive();
    return 0;
}

Compilation message

luck.cpp:6:29: warning: variadic templates only available with -std=c++11 or -std=gnu++11
 template<typename T,typename... Args>
                             ^
luck.cpp:7:25: warning: variadic templates only available with -std=c++11 or -std=gnu++11
 void read(T& a,Args&... b){ read(a); read(b...); }
                         ^
luck.cpp: In function 'void naive()':
luck.cpp:32:64: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
    int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
                                                                ^
luck.cpp:32:65: error: no matching function for call to 'count_if(int*, int*, naive()::<lambda(int)>)'
    int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
                                                                 ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from luck.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3982:5: note: candidate: template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)
     count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
     ^
/usr/include/c++/5/bits/stl_algo.h:3982:5: note:   template argument deduction/substitution failed:
luck.cpp: In substitution of 'template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate) [with _IIter = int*; _Predicate = naive()::<lambda(int)>]':
luck.cpp:32:65:   required from here
luck.cpp:32:65: error: template argument for 'template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)' uses local type 'naive()::<lambda(int)>'
    int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
                                                                 ^
luck.cpp:32:65: error:   trying to instantiate 'template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)'
luck.cpp:38:64: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
    int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
                                                                ^
luck.cpp:38:65: error: no matching function for call to 'count_if(int*, int*, naive()::<lambda(int)>)'
    int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
                                                                 ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from luck.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3982:5: note: candidate: template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)
     count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
     ^
/usr/include/c++/5/bits/stl_algo.h:3982:5: note:   template argument deduction/substitution failed:
luck.cpp: In substitution of 'template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate) [with _IIter = int*; _Predicate = naive()::<lambda(int)>]':
luck.cpp:38:65:   required from here
luck.cpp:38:65: error: template argument for 'template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)' uses local type 'naive()::<lambda(int)>'
    int rnk = count_if(c+1, c+n+1, [&](int x){ return x > c[i]; })+1;
                                                                 ^
luck.cpp:38:65: error:   trying to instantiate 'template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)'
luck.cpp: In function 'void read(int&)':
luck.cpp:5:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 void read(int& x){ scanf("%d",&x); }
                                  ^