萌新求助编译错误
查看原帖
萌新求助编译错误
303025
zjyqwq楼主2021/8/3 22:47

RT,代码如下:

#include<bits/stdc++.h>
using namespace std;
#define R register
#define w_ putchar(' ')
#define wn putchar('\n')
inline void read(R int &y){
   R int s=0,w=1;
   R char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   y=s*w;
}
inline void write(R int x){
    if(x < 0){
        putchar('-');
        write(-x);
        return;
    }
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}
struct node{
	int x,y,z;
	char c;
}t,t1;
void  leftt(char &c){
	if(c=='E'){
		c='N';
	}
	if(c=='N'){
		c='W';
	}
	if(c=='W'){
		c='S';
	}
	if(c=='S'){
		c='E';
	}
}
void rightt(char &c){
	if(c=='N'){
		c='E';
	}
	if(c=='W'){
		c='N';
	}
	if(c=='S'){
		c='W';
	}
	if(c=='E'){
		c='S';
	}
}
struct n2{
	int x,y;
	char c;
}t2;
map<n2,bool>ma;
queue<node> q;
int n,m,qx,qy,zx,zy,a[55][55];
char ch;
signed main(){
	ios::sync_with_stdio(0);
	read(n);read(m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			read(a[i][j]);
		}
	}
	read(qx);read(qy);read(zx);read(zy);cin>>ch;
	t.x=qx,t.y=qy,t.c=ch,t.z=0;
	q.push(t);
	while(q.size()){
		t=q.front();
		if(t.x==zx&&t.y==zy){
			write(t.z);
			return 0;
		}
		t1=t;
		if(t.c=='E'){
			if(t.y+1<=m){
				t1.y+=1;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.y+2<=m){
				t1.y+=2;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.y+3<=m){
				t1.y+=3;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				leftt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				rightt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
		}
		if(t.c=='S'){
			if(t.x+1<=n){
				t1.x+=1;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.x+2<=n){
				t1.x+=2;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.x+3<=n){
				t1.x+=3;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				leftt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				rightt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
		}
		if(t.c=='W'){
			if(t.y-1>=1){
				t1.y-=1;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.y-2>=1){
				t1.y-=2;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.y-3>=1){
				t1.y-=3;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				leftt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				rightt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
		}
		if(t.c=='E'){
			if(t.x-1>=1){
				t1.x-=1;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.x-2>=1){
				t1.x-=2;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(t.x-3>=1){
				t1.x-=3;t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				leftt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
			if(1){
				rightt(t1.c);t1.z+=1;
				t2.x=t1.x;t2.y=t1.y;t2.c=t1.c;
				if(!ma[t2]&&!a[t2.x][t2.y]){
					ma[t2]=true;
					q.push(t1);
				}
				t1=t;	
			}
		}
	}
	write(-1);
}

编译信息:


            In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h: In instantiation of ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = n2]’:
/usr/include/c++/8/bits/stl_map.h:497:32:   required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = n2; _Tp = bool; _Compare = std::less<n2>; _Alloc = std::allocator<std::pair<const n2, bool> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = bool; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = n2]’
/tmp/compiler_xhc_z6e5/src:84:14:   required from here
/usr/include/c++/8/bits/stl_function.h:386:20: 错误:no match for ‘operator<’ (operand types are ‘const n2’ and ‘const n2’)
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/utility:70,
                 from /usr/include/c++/8/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:65,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_pair.h:454:5: 附注:candidate: ‘template<class _T1, class _T2> bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)’
     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
     ^~~~~~~~
/usr/include/c++/8/bits/stl_pair.h:454:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::pair<_T1, _T2>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/bits/stl_algobase.h:67,
                 from /usr/include/c++/8/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:65,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_iterator.h:308:5: 附注:candidate: ‘template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)’
     operator<(const reverse_iterator<_Iterator>& __x,
     ^~~~~~~~
/usr/include/c++/8/bits/stl_iterator.h:308:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::reverse_iterator<_Iterator>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/bits/stl_algobase.h:67,
                 from /usr/include/c++/8/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:65,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_iterator.h:346:5: 附注:candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)’
     operator<(const reverse_iterator<_IteratorL>& __x,
     ^~~~~~~~
/usr/include/c++/8/bits/stl_iterator.h:346:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::reverse_iterator<_Iterator>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/basic_string.h:6133:5: 附注:candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/8/bits/basic_string.h:6133:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/basic_string.h:6146:5: 附注:candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’
     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/8/bits/basic_string.h:6146:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/basic_string.h:6158:5: 附注:candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
     operator<(const _CharT* __lhs,
     ^~~~~~~~
/usr/include/c++/8/bits/basic_string.h:6158:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  mismatched types ‘const _CharT*’ and ‘n2’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/deque:64,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:68,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_deque.h:294:5: 附注:candidate: ‘template<class _Tp, class _Ref, class _Ptr> bool std::operator<(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)’
     operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
     ^~~~~~~~
/usr/include/c++/8/bits/stl_deque.h:294:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/deque:64,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:68,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_deque.h:302:5: 附注:candidate: ‘template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator<(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)’
     operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
     ^~~~~~~~
/usr/include/c++/8/bits/stl_deque.h:302:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/deque:64,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:68,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_deque.h:2295:5: 附注:candidate: ‘template<class _Tp, class _Alloc> bool std::operator<(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)’
     operator<(const deque<_Tp, _Alloc>& __x,
     ^~~~~~~~
/usr/include/c++/8/bits/stl_deque.h:2295:5: 附注:  template argument deduction/substitution failed:
In file included from /usr/include/c++/8/string:48,
                 from /usr/include/c++/8/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:66,
                 from /tmp/compiler_xhc_z6e5/src:1:
/usr/include/c++/8/bits/stl_function.h:386:20: 附注:  ‘const n2’ is not derived from ‘const std::deque<_Tp, _Alloc>’
       { return __x < __y; }
                ~~~~^~~~~
In file included from /usr/include/c++/8/list:63,
                 from /usr/include/x86_64-linux-gnu/c++/8/bits/stdc++.h:79,
                 from /tmp/compiler_x
...
          
2021/8/3 22:47
加载中...