-
Notifications
You must be signed in to change notification settings - Fork 0
/
2564.cpp
62 lines (58 loc) · 1.11 KB
/
2564.cpp
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
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int b_x, b_y;
int total = 0;
int s;
int s_d[100] = {};
int s_p[100] = {};
int d_d, d_p;
cin >> b_x >> b_y>>s; //ºí·Ï °¡·Î, ¼¼·Î, »óÁ¡ ¼ö
for(int i=0;i<s;i++){
cin >> s_d[i] >> s_p[i];
}
cin >> d_d >> d_p;
int map[5][4] = { 0,0,0,0,1,2,3,4,2,1,3,4,3,4,1,2,4,3,1,2 };
int x, y;
if (d_d <= 2) {
x = b_x;
y = b_y;
}
else {
x = b_y;
y = b_x;
}
for (int i = 0; i < s; i++) {
if (s_d[i] == map[d_d][0]) {
total += (abs(s_p[i] - d_p));
}
else if (s_d[i] == map[d_d][1]) {
total += y;
if (d_p + s_p[i] > x * 2 - d_p - s_p[i]) {
total += x * 2 - d_p - s_p[i];
}
else {
total += d_p + s_p[i];
}
}
else if (d_d %2 == 1) {
if (s_d[i] == map[d_d][2]) {
total += (s_p[i] + d_p);
}
else {
total += (s_p[i] + x - d_p);
}
}
else if (d_d % 2 == 0) {
if (s_d[i] == map[d_d][2]) {
total += (y - s_p[i] + d_p);
}
else if (s_d[i] == 4) {
total += (x+y - s_p[i] - d_p);
}
}
}
cout << total;
cin >> total;
}