-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11459.c
More file actions
51 lines (46 loc) · 706 Bytes
/
11459.c
File metadata and controls
51 lines (46 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<stdio.h>
#include<string.h>
int p[1000010];
int main()
{
int t,n,l[101],s[101],roll,s1,e1,flag=0,i,j,r,dice,ls;
int turn;
scanf("%d",&t);
while(t--)
{
memset(l,0,sizeof(l));
memset(s,0,sizeof(s));
flag=0;
scanf("%d%d%d",&n,&ls,&roll);
for(i=0;i<n;i++)
p[i]=1;
for(i=0;i<ls;i++)
{
scanf("%d%d",&s1,&e1);
if(s1>e1)
s[s1]=e1;
else
l[s1]=e1;
}
turn=0;
for(r=0;r<roll;r++)
{
scanf("%d",&dice);
if(flag==0){
p[turn]+=dice;
if(l[p[turn]]>0){
p[turn]=l[p[turn]];
}
else if(s[p[turn]]>0){
p[turn]=s[p[turn]];
}
if(p[turn]==100)
flag=1;
turn=(turn+1)%n;
}
}
for(i=0;i<n;i++)
printf("Position of player %d is %d.\n",i+1,p[i]);
}
return 0;
}