QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545599#7516. Robot ExperimentOneteas#WA 180ms3724kbC++141.6kb2024-09-03 15:27:072024-09-03 15:27:07

Judging History

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

  • [2024-09-03 15:27:07]
  • 评测
  • 测评结果:WA
  • 用时:180ms
  • 内存:3724kb
  • [2024-09-03 15:27:07]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std ;
#define lbt x&-x 
#define int long long 
#define pll pair<int , int > 
#define plll pair<int , pll > 
vector <pll> ans;


int n ;
string s ;
bool vis[50][50] , st[50][50];
map< char , pll > p ;
void solve( ) {
    cin >> n ;
    cin >> s ;
    p['L'] = {-1 , 0 } ;
    p['R'] = { 1 , 0 } ;
    p['U'] = { 0 , 1 } ;
    p['D'] = { 0 , -1 } ;
    for( int i = 0 ; i < ( 1 << n ) ; i ++ ) {
        int x = 25 , y = 25 ;
        memset(vis , 0 , sizeof vis ) ;
        memset(st , 0 , sizeof st ) ;
        vis[25][25] = true ;
        int o = i ;
        bool f = true ;
        for( int j = 0 ; j < n ; j ++ ){
            auto [dx , dy ] = p[s[j]] ;
            if( (i & ( 1 << j )) == 0 ){//0
                if(vis[x + dx][y + dy ] == true) {
                    f = false ;
                }else {
                    st[x + dx][y + dy ] = true;
                }
            }else {
                x += dx , y += dy ;
                if(st[x + dx][y + dy ] == true ) {
                    f = false ;
                }else {
                    vis[x][y] = true ;
                }
            }
        }
        if( f ) ans.push_back({x - 25 , y - 25 }) ;

    }
    sort( ans.begin() , ans.end()) ;
    ans.erase(unique(ans.begin() , ans.end()) , ans.end()) ;
    cout<<ans.size()<<'\n';
    for( auto [x , y ] : ans ) {
        cout << x << ' ' << y << '\n' ;
    }
    return ;

}
signed main( ) {
    ios::sync_with_stdio(false),cin.tie(0) ;
    int _ = 1 ;
    while( _ -- ) {
        solve( ) ; 
    }
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

2
RU

output:

4
0 0
0 1
1 0
1 1

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

4
LRUD

output:

4
0 -1
0 0
1 -1
1 0

result:

ok 5 lines

Test #3:

score: -100
Wrong Answer
time: 180ms
memory: 3724kb

input:

20
LLLRLRLRLLLRLLRLRLLR

output:

6
-6 0
-5 0
-4 0
-1 0
0 0
1 0

result:

wrong answer 1st lines differ - expected: '8', found: '6'