Submission #3079

# Submission time Handle Problem Language Result Execution time Memory
3079 2013-08-24T13:44:15 Z tncks0121 Hexagon travel (kriii1_H) C++
0 / 1
0 ms 1084 KB
#include <stdio.h>

double last[3][6],now[3][6],ans[3];
int col[3][6] = {{1,2,1,2,1,2},{2,0,2,0,2,0},{0,1,0,1,0,1}};
char S[410]; int L,P;

int main()
{
	int i,c,d,nc,nd;

	scanf ("%d %d",&L,&P);
	scanf ("%s",S);

	last[2][0] = 1;
	for (i=0;S[i];i++){
		for (c=0;c<3;c++) for (d=0;d<6;d++) now[c][d] = last[c][d] * P / 100;
		for (c=0;c<3;c++) for (d=0;d<6;d++){
			if (S[i] == 'M') nc = col[c][d], nd = d;
			if (S[i] == 'L') nc = c, nd = (d + 5) % 6;
			if (S[i] == 'R') nc = c, nd = (d + 1) % 6;
			now[nc][nd] += last[c][d] * (100 - P) / 100;
		}
		for (c=0;c<3;c++) for (d=0;d<6;d++) last[c][d] = now[c][d];
	}

	for (c=0;c<3;c++) for (d=0;d<6;d++) ans[c] += last[c][d];
	for (c=0;c<3;c++) printf ("%.9lf\n",ans[c]+1e-9);

	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1084 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -