QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#68832#5112. Where Am I?chenshi#ML 1243ms528324kbC++141.5kb2022-12-21 10:36:092022-12-21 10:36:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-21 10:36:12]
  • 评测
  • 测评结果:ML
  • 用时:1243ms
  • 内存:528324kb
  • [2022-12-21 10:36:09]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int o=1e6;
int n,m,dx[o],dy[o],cnt,ans1,ans2;char s[110][110];
struct State{int sx,sy,x,y;};
vector<State> bg1,bg2,Ans;
void slv(vector<State> vec,int t){
	if(t>=cnt) while(1);
	if((int)vec.size()==1){
		ans1+=--t;
		if(t>ans2) ans2=t,Ans.clear();
		if(t==ans2) Ans.push_back(vec[0]);
		return;
	}
	vector<State> v1,v2;
	for(int i=vec.size();i--;){
		vec[i].x+=dx[t];vec[i].y+=dy[t];
		if(vec[i].x>=1&&vec[i].x<=n&&vec[i].y>=1&&vec[i].y<=m&&s[vec[i].x][vec[i].y]=='X') v1.push_back(vec[i]);
		else v2.push_back(vec[i]);
	}
	vec.clear();
	if(!v1.empty()) slv(v1,t+1);
	if(!v2.empty()) slv(v2,t+1);
}
inline bool cmp(State A,State B){if(A.sy^B.sy) return A.sy<B.sy;return A.sx<B.sx;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<200;++i){
		for(int j=1;j<2*i;++j) dx[++cnt]=0,dy[cnt]=1;
		for(int j=1;j<2*i;++j) dx[++cnt]=1,dy[cnt]=0;
		for(int j=1;j<=2*i;++j) dx[++cnt]=0,dy[cnt]=-1;
		for(int j=1;j<=2*i;++j) dx[++cnt]=-1,dy[cnt]=0;
	}
	for(int j=1;j<=m;++j) for(int i=1;i<=n;++i)
		do s[i][m-j+1]=getchar();while(s[i][m-j+1]-'X'&&s[i][m-j+1]-'.');
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j)
		if(s[i][j]=='X') bg1.push_back((State){i,j,i,j});
		else bg2.push_back((State){i,j,i,j});
	slv(bg1,1);slv(bg2,1);
	printf("%.5lf\n%d\n",ans1*1.0/(n*m),ans2);
	sort(Ans.begin(),Ans.end(),cmp);
	for(int i=0,sz=Ans.size();i<sz;++i) printf("(%d,%d) ",Ans[i].sx,Ans[i].sy);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 4328kb

input:

1 1
X

output:

0.00000
0
(1,1) 

result:

ok correct!

Test #2:

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

input:

2 1
.X

output:

0.00000
0
(1,1) (2,1) 

result:

ok correct!

Test #3:

score: 0
Accepted
time: 3ms
memory: 4244kb

input:

2 1
X.

output:

0.00000
0
(1,1) (2,1) 

result:

ok correct!

Test #4:

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

input:

1 2
.
X

output:

0.00000
0
(1,1) (1,2) 

result:

ok correct!

Test #5:

score: 0
Accepted
time: 2ms
memory: 4184kb

input:

1 2
X
.

output:

0.00000
0
(1,1) (1,2) 

result:

ok correct!

Test #6:

score: 0
Accepted
time: 3ms
memory: 4416kb

input:

2 1
XX

output:

3.00000
3
(1,1) (2,1) 

result:

ok correct!

Test #7:

score: 0
Accepted
time: 3ms
memory: 4248kb

input:

3 3
XXX
X.X
XXX

output:

3.11111
5
(3,1) (3,2) 

result:

ok correct!

Test #8:

score: 0
Accepted
time: 1243ms
memory: 528324kb

input:

100 100
..X....X....X....X....X....X....X....X....X....X....X....X....X....X....X....X....X....X....X....X..
....................................................................................................
X............................................................................................

output:

4757.94710
9704
(50,1) (50,100) 

result:

ok correct!

Test #9:

score: -100
Memory Limit Exceeded

input:

100 100
X...................................................................................................
....................................................................................................
.............................................................................................

output:


result: