QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#220795#7516. Robot Experimentammardab3an#WA 1ms3548kbC++201012b2023-10-20 20:40:422023-10-20 20:40:42

Judging History

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

  • [2023-10-20 20:40:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3548kb
  • [2023-10-20 20:40:42]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int n;
string s;

map<pair<int, int>, int> mp;
multiset<pair<int, int>> vis;
multiset<pair<int, int>> block;

void go(int i, int j, int idx){
    
    if(idx == n){	
		mp[{i, j}] = 1;
		return;
    }
    
	pair<int, int> nxt;
    if(s[idx] == 'U') nxt = {i+1, j};
    else if(s[idx] == 'D') nxt = {i-1, j};
    else if(s[idx] == 'R') nxt = {i, j+1};
    else nxt = {i, j-1};
	
    if(vis.find(nxt) == vis.end()){
        block.insert(nxt);
        go(i, j, idx+1);
        block.erase(block.find(nxt));
    }
    if(block.find(nxt) == block.end()){
        vis.insert(nxt);
        go(nxt.first, nxt.second, idx+1);
        vis.erase(vis.find(nxt));
    } else {
        assert(nxt != make_pair(0, 0));
    }
}

int main()
{

    cin >> n >> s;

    vis.insert({0, 0});
    go(0, 0, 0);

    cout << (int)mp.size() << "\n";

    for(auto [f, s] : mp) cout << f.first << " " << f.second << "\n";

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3548kb

input:

2
RU

output:

4
0 0
0 1
1 0
1 1

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3428kb

input:

4
LRUD

output:

4
-1 0
-1 1
0 0
0 1

result:

wrong answer 2nd lines differ - expected: '0 -1', found: '-1 0'