QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545588#7516. Robot ExperimentOneteas#WA 0ms3716kbC++141.6kb2024-09-03 15:17:142024-09-03 15:17:15

Judging History

This is the latest submission verdict.

  • [2024-09-03 15:17:15]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3716kb
  • [2024-09-03 15:17:14]
  • Submitted

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()) ;
    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: 0
Wrong Answer
time: 0ms
memory: 3716kb

input:

2
RU

output:

0 0
0 1
1 0
1 1

result:

wrong answer 1st lines differ - expected: '4', found: '0 0'