QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408927 | #6539. Treasure Box | Doqe | Compile Error | / | / | C++23 | 1.1kb | 2024-05-11 12:15:33 | 2024-05-11 12:15:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int nd[N],V[N];
long long val[N];
char s[N];
int main()
{
int T;cin>>T;
while(T--)
{
int n,C,pl=0,pr=0;
cin>>n>>C>>s+1;
for(int i=1;i<=n;++i)cin>>V[i];
for(int i=1;i<=n;++i)nd[i]=s[i]!=s[n-i+1],val[i]=1e18;
for(int i=1;i<=n;++i)if(nd[i])pr=i;
if(!pr){for(int i=1;i<=n;++i)cout<<"0 ";cout<<"\n";continue;}
pl=n-pr+1;
{
long long mn=0,t;int z;
for(int i=pr;i>n/2;--i)if(nd[i])mn+=V[i],z=i;
val[pr]=1ll*(pr-z)*C+mn;
for(int i=n/2;i>pl;--i)
{
if(nd[i])mn-=V[n-i+1]-min(V[i],V[n-i+1]),
val[pr]=min(val[pr],1ll*(pr-i)*C+mn);
val[i]=1ll*(pr-i)*C+mn;
}
}
{
long long mn=0;int z;
for(int i=pl;i<=n/2;++i)if(nd[i])mn+=V[i],z=i;
val[pl]=1ll*(z-pl)*C+mn;
for(int i=n/2+1;i<pr;++i)
{
if(nd[i])mn-=V[n-i+1]-min(V[i],V[n-i+1]),
val[pr]=min(val[pr],1ll*(i-pl)*C+mn);
val[i]=1ll*(i-pl)*C+mn;
}
}
for(int i=2;i<=n;++i)val[i]=min(val[i],val[i-1]+C);
for(int i=n-1;i;--i)val[i]=min(val[i],val[i+1]+C);
for(int i=1;i<=n;++i)cout<<val[i]<<' ';cout<<"\n";
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:13:26: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘char*’) 13 | cin>>n>>C>>s+1; | ~~~~~~~~~^~~~~ | | | | | char* | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from answer.code:1: /usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 325 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/13/istream:325:7: note: conversion of argument 1 would be ill-formed: answer.code:13:29: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’ 13 | cin>>n>>C>>s+1; | ~^~ /usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 201 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:201:7: note: conversion of argument 1 would be ill-formed: answer.code:13:29: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive] 13 | cin>>n>>C>>s+1; | ~^~ | | | char* answer.code:13:29: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s)) + 1)’ to ‘long long unsigned int&’ /usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 197 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:197:7: note: conversion of argument 1 would be ill-formed: answer.code:13:29: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive] 13 | cin>>n>>C>>s+1; | ~^~ | | | char* answer.code:13:29: error: cannot bind rvalue ‘(long long int)(((char*)(& s)) + 1)’ to ‘long long int&’ /usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:192:7: note: conversion of argument 1 would be ill-formed: answer.code:13:29: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive] 13 | cin>>n>>C>>s+1; | ~^~ | | | char* answer.code:13:29: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& s)) + 1)’ to ‘long unsigned int&’ /usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:188:7: note: conversion of argument 1 would be ill-formed: answer.code:13:29: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive] 13 | cin>>n>>C>>s+1; | ~^~ | | | char* answer.code:13:29: error: cannot bind rvalue ‘(long int)(((char*)(& s)) + 1)’ to ‘long int&’ /usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/13/istream:184:7: note: conversion of argument 1 would be ill-formed: answer.code:13:2...