Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <vector>
- #include <map>
- #include <set>
- #include <cmath>
- #define For(a) for ( i = 0; i < a; i++ )
- #define Rep(a, b) for ( i = a; i <= b; i++ )
- #define N 1000000
- using namespace std;
- struct point{
- bool obs;
- int score;
- int cost;
- }Pinball[52][52];
- int tot;
- int mover(int * x, int * y, int * dir, int * lt)
- {
- int newx=*x, newy=*y;
- int score=0;
- (*lt)--;
- if (*lt<=0) {
- return 0;/*si la vida se acaba*/
- }
- switch(*dir) {
- case 0: newx += 1; break;
- case 1: newy += 1; break;
- case 2: newx -= 1; break;
- case 3: newy -= 1; break;
- }
- if (Pinball[newx][newy].obs==true) {
- score = Pinball[newx][newy].score;
- *lt -= Pinball[newx][newy].cost;
- newx=*x;
- newy=*y;
- *dir=(*dir+3)%4;
- }
- *x=newx;
- *y=newy;
- return score;
- }
- int main() {
- int m,n,c,p,valor,cost,dir,life,score,x,y;
- scanf("%d %d",&m,&n);
- scanf("%d",&c);
- scanf("%d",&p);
- tot=0;
- for(int i=1;i<=m;i++){
- for(int j=1;j<=n;j++){
- if (i==1 || j==1 || i==m || j==n) {
- Pinball[i][j].obs=true;
- Pinball[i][j].score=0;
- Pinball[i][j].cost=c;
- } else {
- Pinball[i][j].obs=0;
- }
- }
- }
- for (int i=0;i<p;i++){
- scanf("%d %d %d %d", &x, &y, &valor, &cost);
- Pinball[x][y].obs=true;
- Pinball[x][y].score=valor;
- Pinball[x][y].cost=cost;
- }
- while(scanf("%d %d %d %d",&x,&y,&dir,&life)==4){
- score=0;
- while(life>0){
- score+=mover(&x,&y,&dir,&life);
- }
- tot += score;
- printf("%d\n", score);
- }
- printf("%d\n", tot);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement