| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
嗯水#include <iostream>
#include <stdio.h>
using namespace std;
int dif[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
int main() {
int n,m;
scanf("%d%d", &m, &n);
int wC;
scanf("%d", &wC);
int numB;
scanf("%d", &numB);
bool isBumper[60][60] = {0};
int val[60][60], cost[60][60];
for(int j = 1; j <= n; j++){
isBumper[1][j] = isBumper[m][j] = 1;
val[1][j] = val[m][j] = 0;
cost[1][j] = cost[m][j] = wC;
}
for(int i = 2; i < m; i++){
isBumper[i][1] = isBumper[i][n] = 1;
val[i][1] = val[i][n] = 0;
cost[i][1] = cost[i][n] = wC;
}
for(int i = 0; i < numB; i++){
int x, y, v, c;
scanf("%d%d%d%d", &x, &y, &v, &c);
isBumper[x][y] = 1;
val[x][y] = v;
cost[x][y] = c;
}
int tS = 0;
int bx, by, dir, pt;
while(scanf("%d%d%d%d", &bx, &by, &dir, &pt) == 4){
int sc = 0;
while(pt > 1){
int nbx = bx + dif[dir][0], nby = by + dif[dir][1];
if(!isBumper[nbx][nby]){
pt--;
bx = nbx;
by = nby;
}
else{
dir = (dir+3)%4;
pt--;
pt -= cost[nbx][nby];
sc += val[nbx][nby];
}
}
tS += sc;
printf("%d\n", sc);
}
printf("%d\n", tS);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator