QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687438#7516. Robot Experimenticpc_zhzx034#AC ✓57ms4108kbC++141.7kb2024-10-29 19:03:292024-10-29 19:03:31

Judging History

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

  • [2024-10-29 19:03:31]
  • 评测
  • 测评结果:AC
  • 用时:57ms
  • 内存:4108kb
  • [2024-10-29 19:03:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pr;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
// #define mid ((l+r)>>1)
#define popcnt __builtin_popcountll
const ll mod = 998244353;
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
	ll ans=1, base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod; b>>=1;
	}
	return ans;
}
void init(){ }
ll n; char s[25];
int vis[41][41], pos[41][41];
void procedure(){
	n=read();
	scanf("%s", s);
	for(int S=0;S<(1<<n);S++){
		memset(vis,-1,sizeof(vis));
		int x=20, y=20; vis[x][y]=0;
		bool flg=1;
		for(int i=0;i<n;i++){
			if(s[i]=='L') x--;
			if(s[i]=='R') x++;
			if(s[i]=='D') y--;
			if(s[i]=='U') y++;
			if((S>>i)&1){
				if(vis[x][y]==1) {
					flg=0;
					break;
				}
				vis[x][y]=0;
			}else{
				if(vis[x][y]==0) {
					flg=0;
					break;
				}
				vis[x][y]=1;
				if(s[i]=='R') x--;
				if(s[i]=='L') x++;
				if(s[i]=='U') y--;
				if(s[i]=='D') y++;
			}
		}
		if(flg) pos[x][y]=1;

		// cout<<"solved "<<S<<endl;
	}
	vector<Pr>v;
	for(int x=0;x<=40;x++){
		for(int y=0;y<=40;y++){
			if(pos[x][y]) v.pb(x-20, y-20);
		}
	}
	printf("%lld\n", (ll)v.size());
	for(auto p: v) printf("%lld %lld\n", p.fi, p.se);
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	ll T=1;
	init();
	while(T--) procedure();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

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: 4072kb

input:

4
LRUD

output:

4
0 -1
0 0
1 -1
1 0

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 41ms
memory: 3828kb

input:

20
LLLRLRLRLLLRLLRLRLLR

output:

8
-6 0
-5 0
-4 0
-3 0
-2 0
-1 0
0 0
1 0

result:

ok 9 lines

Test #4:

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

input:

1
D

output:

2
0 -1
0 0

result:

ok 3 lines

Test #5:

score: 0
Accepted
time: 50ms
memory: 4068kb

input:

20
UUUUUUUUUUUUUUUUUUUU

output:

21
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20

result:

ok 22 lines

Test #6:

score: 0
Accepted
time: 51ms
memory: 3800kb

input:

20
LRUDDULRUDRLLRDURLUD

output:

22
-2 0
-2 1
-1 -2
-1 -1
-1 0
-1 1
-1 2
0 -2
0 -1
0 0
0 1
0 2
1 -2
1 -1
1 0
1 1
1 2
2 -2
2 -1
2 0
2 1
2 2

result:

ok 23 lines

Test #7:

score: 0
Accepted
time: 49ms
memory: 3756kb

input:

20
UUDUDUUDUDUDUDUDLLRL

output:

12
-2 -1
-2 0
-2 1
-2 2
-1 -1
-1 0
-1 1
-1 2
0 -1
0 0
0 1
0 2

result:

ok 13 lines

Test #8:

score: 0
Accepted
time: 49ms
memory: 4108kb

input:

20
DUUDDUDUUDUDDUUDUDDU

output:

3
0 -1
0 0
0 1

result:

ok 4 lines

Test #9:

score: 0
Accepted
time: 49ms
memory: 4064kb

input:

20
RUDLUULDRURLDURLDURR

output:

29
-3 3
-3 4
-2 2
-2 3
-2 4
-1 1
-1 2
-1 3
-1 4
0 -1
0 0
0 1
0 2
0 3
0 4
1 -1
1 0
1 1
1 2
1 3
2 -1
2 0
2 1
2 2
2 3
3 -1
3 0
3 1
3 2

result:

ok 30 lines

Test #10:

score: 0
Accepted
time: 57ms
memory: 3816kb

input:

20
DLDLDLDLLLDLLDLDLDLR

output:

108
-10 -8
-10 -7
-10 -6
-10 -5
-10 -4
-10 -3
-10 -2
-10 -1
-10 0
-9 -8
-9 -7
-9 -6
-9 -5
-9 -4
-9 -3
-9 -2
-9 -1
-9 0
-8 -8
-8 -7
-8 -6
-8 -5
-8 -4
-8 -3
-8 -2
-8 -1
-8 0
-7 -8
-7 -7
-7 -6
-7 -5
-7 -4
-7 -3
-7 -2
-7 -1
-7 0
-6 -8
-6 -7
-6 -6
-6 -5
-6 -4
-6 -3
-6 -2
-6 -1
-6 0
-5 -8
-5 -7
-5 -6
-5 -...

result:

ok 109 lines

Extra Test:

score: 0
Extra Test Passed