QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545600 | #7516. Robot Experiment | 2229059239 | WA | 181ms | 3720kb | C++14 | 1.6kb | 2024-09-03 15:27:15 | 2024-09-03 15:27:15 |
Judging History
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: 3688kb
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: 3656kb
input:
4 LRUD
output:
4 0 -1 0 0 1 -1 1 0
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 181ms
memory: 3720kb
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'