#B. C++-联合和枚举-取数

    Type: Default 1000ms 256MiB

C++-联合和枚举-取数

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

Description

取数。 有一个N*N的二维网格,每格里面有1个整数。现在给定开始的位置(x, y)和方向(上、下、左和右之一),一直移动到网格的边界,计算移动过程中线路上格子里的数字和。 输入格式 :1行,4个整数,第1个整数N,范围在[1...1000],第2、3个整数是开始位置的坐标X和Y,表示在第X行Y列(编号1到N),第4个整数D表示方向,D=0表示向上,D=1表示向下,D=2表示向左,D=3表示向右;下面N行,每行N个整数,范围在[-1000...1000] image

Format

Input

Output

Samples

4 2 3 2
1 2 3 4
5 9 8 7
8 2 7 4
6 6 3 8
输入
输出
22
5 3 3 1
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
输入
输出
54
5 3 3 3
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
输入
输出
42

Limitation

1s, 1024KiB for each test case.

联合和枚举

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
3
Start at
2024-5-5 0:00
End at
2024-5-20 0:00
Duration
360 hour(s)
Host
Partic.
6