답안 #305803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305803 2020-09-24T01:34:24 Z T0p_ Exhibition (JOI19_ho_t2) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

struct picture
{
	int s, v;
	bool operator < (const picture & o) const
	{
		return v < o.v;	
	}
};

picture p[100100];
int f[100100], dp[100100];
stack<int> stk, tmp;

int main()
{
	int n, m;
	scanf(" %d %d",&n,&m);
	for(int i=1 ; i<=n ; i++)
		scanf(" %d %d",&p[i].s,&p[i].v);
	for(int i=1 ; i<=m ; i++)
		scanf(" %d",&f[i]);
	sort(p+1, p+n+1);
	sort(f+1, f+m+1);
	stk.push(0);
	for(int i=1 ; i<=n ; i++)
	{	
		int l = 1, r = m+1;
		while(l != r)
		{
			int mid = (l+r)>>1;
			(p[i].s <= f[mid]) ? r = mid : l = mid+1;
		}
		if(l == m+1) continue ;
		while(l <= stk.top())
		{
			dp[stk.top() + 1] = max(dp[stk.top()+1], dp[stk.top()] + 1);
			tmp.push(stk.top() + 1);
			stk.pop();
		}
		dp[l] = max(dp[l], [stk.top()] + 1);
		stk.push(l);
		while(!tmp.empty())
		{
			stk.push(tmp.top());
			tmp.pop();
		}
	}
	int ans = 0;
	for(int i=1 ; i<=m ; i++)
		ans = max(ans, dp[i]);
	printf("%d\n",ans);
	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:43:23: warning: capture of variable 'stk' with non-automatic storage duration
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                       ^~~
joi2019_ho_t2.cpp:15:12: note: 'std::stack<int> stk' declared here
   15 | stack<int> stk, tmp;
      |            ^~~
joi2019_ho_t2.cpp:43:26: error: expected ',' before '.' token
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                          ^
      |                          ,
joi2019_ho_t2.cpp:43:26: error: expected identifier before '.' token
joi2019_ho_t2.cpp: In lambda function:
joi2019_ho_t2.cpp:43:34: error: expected '{' before '+' token
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                  ^
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:43:34: error: no match for 'operator+' (operand types are 'main()::<lambda()>' and 'int')
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:423:5: note: candidate: 'template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)'
  423 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:423:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:1219:5: note: candidate: 'template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)'
 1219 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6020:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6020 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6020:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.tcc:1158:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 1158 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1158:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   mismatched types 'const _CharT*' and 'main()::<lambda()>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.tcc:1174:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 1174 |     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1174:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6057:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 6057 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6057:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6073:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 6073 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6073:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6085:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6085 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6085:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6091:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6091 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6091:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6097:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6097 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6097:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6109:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6109 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6109:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   mismatched types 'const _CharT*' and 'main()::<lambda()>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6115:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6115 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6115:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6121:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)'
 6121 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6121:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6127:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)'
 6127 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6127:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/complex:327:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const std::complex<_Tp>&)'
  327 |     operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:327:5: note:   template argument deduction/substitution failed:
joi2019_ho_t2.cpp:43:36: note:   'main()::<lambda()>' is not derived from 'const std::complex<_Tp>'
   43 |   dp[l] = max(dp[l], [stk.top()] + 1);
      |                                    ^
In file included from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from joi2019_ho_t2.cpp:1:
/usr/include/c++/9/complex:336:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const _Tp&)'
  336 |     operator+(const compl