QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610867 | #9417. Palindromic Polygon | Rosmontispes | Compile Error | / | / | C++20 | 3.0kb | 2024-10-04 17:49:59 | 2024-10-04 17:50:03 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1000 + 200;
const long long inf = 0x3f3f3f3f3f3f3f3f;
struct Point{
long long x,y;
Point(long long _x = 0,long long _y = 0):x(_x),y(_y){}
};
long long cross(Point a,Point b){
return a.x * b.y - a.y * b.x;
}
long long g[N][N];
long long count(vector<Point>res){
long long S = 0;
for(int i = 0;i < (int)res.size();i ++){
int nex = i + 1 == (int)res.size()?0:i + 1;
S += cross(res[i],res[nex]);
}
return llabs(S);
}
void solve()
{
int n;
cin>>n;
vector<int>f(2 * n);
vector<Point>p(2 * n);
for(int i = 0;i < n;i ++)
cin>>f[i],f[i + n] = f[i];
map<int,vector<int>>M;
for(int i = 0;i < 2 * n;i ++)
M[f[i]].push_back(i);
for(int i = 0;i < n;i ++){
long long x,y;
cin>>x>>y;
p[i] = Point(x,y);
p[i + n] = Point(x,y);
}
for(int i = 0;i <= 2 * n;i ++)
for(int j = 0;j <= 2 * n;j ++)
g[i][j] = -inf;
for(int i = 0;i < 2 * n;i ++)
g[i][i] = 0;
long long ans = 0;
for(int len = 2;len <= n;len ++){
for(int i = 0;i < n;i ++){
if(f[i] == f[i + len - 1]){
g[i][i + len - 1] = max(g[i][i + len - 1],0);
for(int j = i + 1;j <= i + len - 2;j ++){
auto &vec = M[f[j]];
auto it = lower_bound(vec.begin(),vec.end(),i + len - 1);
it --;
vector<Point>res;
res.push_back(p[i]);
if(j == *it)
res.push_back(p[j]);
else
res.push_back(p[j]),res.push_back(p[*it]);
res.push_back(p[i + len - 1]);
long long sum = count(res) + g[j][*it];
ans = max(ans,sum);
if(sum > g[i][i + len - 1]){
g[i][i + len - 1] = sum;
}
if(*it != j){
it --;
res.clear();
res.push_back(p[i]);
if(j == *it)
res.push_back(p[j]);
else
res.push_back(p[j]),res.push_back(p[*it]);
res.push_back(p[i + len - 1]);
sum = count(res) + g[j][*it];
ans = max(ans,sum);
if(sum > g[i][i + len - 1]){
g[i][i + len - 1] = sum;
}
}
}
}
}
}
cout<<ans<<"\n";
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cout<<fixed<<setprecision(12);
int T=1;
cin>>T;
while(T--)
{
solve();
}
}
/*
1
4
1 2 1 1
1000000000 1000000000
-1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
*/
Details
answer.code: In function ‘void solve()’: answer.code:48:40: error: no matching function for call to ‘max(long long int&, int)’ 48 | g[i][i + len - 1] = max(g[i][i + len - 1],0); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:48:40: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 48 | g[i][i + len - 1] = max(g[i][i + len - 1],0); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: answer.code:48:40: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 48 | g[i][i + len - 1] = max(g[i][i + len - 1],0); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: answer.code:48:40: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 48 | g[i][i + len - 1] = max(g[i][i + len - 1],0); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: answer.code:48:40: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 48 | g[i][i + len - 1] = max(g[i][i + len - 1],0); | ~~~^~~~~~~~~~~~~~~~~~~~~