답안 #592382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592382 2022-07-09T06:35:36 Z starchan Laugh Analysis (IOI16_laugh) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "laugh.h"
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
string life;
struct data
{
	int pref, suff, len, sub;
};
data value(int l, int r)
{
	data val;
	int m = (l+r)/2;
	if(l==r)
	{
		if(life[m] == 'a' || life[m] == 'h')
		{
			val.pref = 1;
			val.suff = 1;
			val.len = 1;
			val.sub = 1;
		}
		else
		{
			val.pref = 0;
			val.suff = 0;
			val.len = 1;
			val.sub = 0;
		}
		return val;
	}
	data d1 = value(l, m);
	data d2 = value(m+1, r);
	val.pref = max(d1.pref, ((d1.pref==d1.len) && (life[m]!=life[m+1]))*(d1.len+d2.pref));
	val.suff = max(d2.suff, ((d2.suff==d2.len) && (life[m]!=life[m+1]))*(d2.len+d1.suff));
	val.len = d1.len+d2.len;
	val.sub = max({d1.sub, d2.sub, (life[m]!=life[m+1])*(d1.suff+d2.pref)});
	return val;
}
int longest_laugh(string s)
{
	life = s;
	return value(0, life.length()-1).sub; 
}

Compilation message

laugh.cpp:18:1: error: reference to 'data' is ambiguous
   18 | data value(int l, int r)
      | ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from laugh.cpp:1:
/usr/include/c++/10/bits/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:310:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:300:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:290:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
laugh.cpp:14:8: note:                 'struct data'
   14 | struct data
      |        ^~~~
laugh.cpp:48:5: error: ambiguating new declaration of 'long long int longest_laugh(std::string)'
   48 | int longest_laugh(string s)
      |     ^~~~~~~~~~~~~
In file included from laugh.cpp:2:
laugh.h:5:5: note: old declaration 'int longest_laugh(std::string)'
    5 | int longest_laugh(std::string s);
      |     ^~~~~~~~~~~~~
laugh.cpp: In function 'long long int longest_laugh(std::string)':
laugh.cpp:51:9: error: 'value' was not declared in this scope
   51 |  return value(0, life.length()-1).sub;
      |         ^~~~~