QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#548689#7516. Robot ExperimentStelorCompile Error//C++17857b2024-09-05 20:08:372024-09-05 20:08:37

Judging History

你现在查看的是最新测评结果

  • [2024-09-05 20:08:37]
  • 评测
  • [2024-09-05 20:08:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<array<int,3>> mp;
vector<pair<int,int>> ans;
void dfs(int x,int y,int now)
{
	if(mp.count({x,y,now})) return;
	if(now==n+1) 
	{
		ans.push_back({x,y});
		return;
	}
	mp.count({x,y,now})=1;
	dfs(x,y,now+1);
	if(s[now]=='L')
	{
		dfs(x-1,y,now+1);
	}
	else if(s[now]=='R')
	{
		dfs(x+1,y,now+1);
	}
	else if(s[now]=='U') 
	{
		dfs(x,y+1,now+1);
	}
	else if(s[now]=='D')
	{
		dfs(x,y-1,now+1);
	}
}
void solve()
{
	cin>>n>>s;
	s="#"+s;
	dfs(0,0,1); 
	sort(ans.begin(),ans.end(),[&](auto u,auto j)
	{
	    if(u.first==u.second) return u.second<j.second;
		else return u.first<j.second;	
	});
	cout<<ans.size()<<'\n';
	for(auto [i,j]) 
	{
		cout<<i<<" "<<j<<"\n";
	}
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	solve();
	return 0; 
}

详细

answer.code:5:16: error: wrong number of template arguments (1, should be at least 2)
    5 | map<array<int,3>> mp;
      |                ^~
In file included from /usr/include/c++/13/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_map.h:102:11: note: provided for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
  102 |     class map
      |           ^~~
answer.code: In function ‘void dfs(int, int, int)’:
answer.code:9:15: error: request for member ‘count’ in ‘mp’, which is of non-class type ‘int’
    9 |         if(mp.count({x,y,now})) return;
      |               ^~~~~
answer.code:15:12: error: request for member ‘count’ in ‘mp’, which is of non-class type ‘int’
   15 |         mp.count({x,y,now})=1;
      |            ^~~~~
answer.code: In function ‘void solve()’:
answer.code:45:23: error: expected initializer before ‘)’ token
   45 |         for(auto [i,j])
      |                       ^
answer.code:45:23: error: expected ‘;’ before ‘)’ token
   45 |         for(auto [i,j])
      |                       ^
      |                       ;
answer.code:45:23: error: expected primary-expression before ‘)’ token
answer.code:45:23: error: expected ‘;’ before ‘)’ token
   45 |         for(auto [i,j])
      |                       ^
      |                       ;