QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234956 | #7636. Fair Elections | ucup-team1004 | Compile Error | / | / | C++14 | 2.9kb | 2023-11-02 07:18:30 | 2023-11-02 07:18:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#ifdef DEBUG
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
cerr<<x<<' ',debug(y...);
}
#else
#define debug(...) void()
#endif
const int N=1e4+10;
int n,a[3],p[N][3];
struct seg{
int l,r;
seg(int x=1,int y=0):l(x),r(y){}
bool empty()const{
return l>r;
}
seg operator | (const seg &x)const{
if(empty())return x;
if(x.empty())return *this;
return seg(min(l,x.l),max(r,x.r));
}
seg operator |= (const seg &x){
return *this=*this|x;
}
seg operator & (const seg &x)const{
if(empty())return *this;
if(x.empty())return x;
return seg(max(l,x.l),min(r,x.r));
}
#ifdef DEBUG
friend ostream& operator << (ostream &out,const seg &x){
return out<<'('<<x.l<<','<<x.r<<')';
}
#endif
seg operator - (const seg &x)const{
if(x.empty()||empty())return *this;
if(x.l>r||x.r<l)return *this;
else if(r<=x.r)return seg(l,x.l-1);
else if(x.l<=l)return seg(x.r+1,r);
else{
cout<<*this<<' '<<x<<endl;
return 0;
}
}
seg operator - (const int &x)const{
return seg(l-x,r-x);
}
}f[2][N][3];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=0;j<3;j++){
cin>>p[i][j],p[i][j]--;
}
}
int now=0,las=1;
for(a[0]=0;a[0]<=n;a[0]++){
for(a[1]=0;a[0]+a[1]<=n;a[1]++){
a[2]=n-a[0]-a[1];
int ans=0;
for(int i=1;i<3;i++)if(a[ans]<a[i])ans=i;
// debug(f[n+1][a[0]][ans],seg(a[1],a[1]),f[n+1][a[0]][ans]|seg(a[1],a[1]));
f[now][a[0]][ans]|=seg(a[1],a[1]);
}
// for(int j=0;j<3;j++){
// debug(n+1,a[0],j,f[n+1][a[0]][j]);
// }
}
for(int i=n;i>=1;i--){
swap(now,las);
for(int j=0;j<3;j++){
for(int k=0;k<i;k++)f[now][k][j]=seg();
}
for(int j=0;j<3;j++){
if(p[i][j]==0){
for(int k=0;k<i;k++){
// debug(0,i,j,k,f[i+1][k+1][0]&seg(0,i-1-k),f[i][k][1],f[i][k][2]);
f[now][k][0]|=(f[las][k+1][0]&seg(0,i-1-k))-(f[now][k][1]|f[now][k][2]);
}
}else if(p[i][j]==1){
for(int k=0;k<i;k++){
// debug(1,i,j,k,(f[i+1][k][1]-1)&seg(0,i-1-k),f[i][k][0],f[i][k][2]);
f[now][k][1]|=((f[las][k][1]-1)&seg(0,i-1-k))-(f[now][k][0]|f[now][k][2]);
}
}else{
for(int k=0;k<i;k++){
// debug(2,i,j,k,f[i+1][k][2]&seg(0,i-1-k),f[i][k][0],f[i][k][1]);
f[now][k][2]|=(f[las][k][2]&seg(0,i-1-k))-(f[now][k][0]|f[now][k][1]);
}
}
}
// for(int j=0;j<3;j++){
// debug(n+1,a[0],j,f[n+1][a[0]][j]);
// }
}
for(int j=0;j<3;j++){
if(!f[now][0][j].empty())cout<<j+1<<endl;
}
return 0;
}
Details
answer.code: In member function ‘seg seg::operator-(const seg&) const’: answer.code:59:29: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘const seg’) 59 | cout<<*this<<' '<<x<<endl; | ~~~~^~~~~~~ | | | | | const seg | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/11/istream:39, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/ostream:108:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 108 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/11/ostream:108:36: note: no known conversion for argument 1 from ‘const seg’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)’ {aka ‘std::basic_ostream<char>& (*)(std::basic_ostream<char>&)’} 108 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/ostream:117:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]’ 117 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/11/ostream:117:32: note: no known conversion for argument 1 from ‘const seg’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’} 117 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/11/ostream:127:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 127 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/11/ostream:127:30: note: no known conversion for argument 1 from ‘const seg’ to ‘std::ios_base& (*)(std::ios_base&)’ 127 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/11/ostream:166:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 166 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/11/ostream:166:23: note: no known conversion for argument 1 from ‘const seg’ to ‘long int’ 166 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/11/ostream:170:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 170 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/11/ostream:170:32: note: no known conversion for argument 1 from ‘const seg’ to ‘long unsigned int’ 170 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/11/ostream:174:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]’ 174 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/11/ostream:174:23: note: no known conversion for argument 1 from ‘const seg’ to ‘bool’ 174 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/11/ostream:853, from /usr/include/c++/11/istream:39, ...