-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11459.c
42 lines (41 loc) · 1.1 KB
/
11459.c
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
#include<stdio.h>
#include<memory.h>
#include<stdlib.h>
int main(){
int board[101], *players, cases, a, b, c, i, ended, s, e, roll, count, p;
scanf("%d", &cases);
players = (int *)malloc(1000010 * sizeof(int));
while(cases--){
memset(board, 0, sizeof(board));
count = ended = 0;
scanf("%d %d %d", &a, &b, &c);
for (i = 1; i <= a; i++){
players[i] = 1;
}
while(b--){
scanf("%d %d", &s, &e);
board[s] = e;
}
while(c--){
scanf("%d", &roll);
if (!ended){
p = ++count % a;
if (!p){
p = a;
}
players[p] += roll;
if (board[players[p]]){
players[p] = board[players[p]];
}
if (players[p] >= 100){
ended = 1;
players[p] = 100;
}
}
}
for (i = 1; i <= a; i++){
printf("Position of player %d is %d.\n", i, players[i]);
}
}
return 0;
}