define _CRT_SECURE_NO_WARNI NGS include iostream include vector includ

 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#define pii pair<long long, long long>
using namespace std;
int N, M;
struct node{
int pos, cond;
node(){}
node(int _pos, int _cond) : pos(_pos), cond(_cond) {}
node(int n, int m, int _cond) : pos(n * M + m), cond(_cond) {}
bool operator < (const node &a) const { return (pos == a.pos ? cond < a.cond : pos < a.pos); }
bool operator ==(const node &a) const { return (pos == a.pos && cond == a.cond); }
};
int permutate[4][24] = { { 10, 5, 13, 18, 9, 21, 14, 3, 2, 17, 22, 6, 4, 20, 19, 0, 1, 12, 23, 11, 8, 16, 15, 7 },
{ 3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14, 19, 16, 17, 18, 23, 20, 21, 22 },
{ 1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12, 17, 18, 19, 16, 21, 22, 23, 20 },
{ 15, 16, 8, 7, 12, 1, 11, 23, 20, 4, 0, 19, 17, 2, 6, 22, 21, 9, 3, 14, 13, 5, 10, 18 } };
map<node, vector<node> > g;
vector<pair<int, int> > H;
vector<pair<int, int> > V;
void init();
int main(){
freopen("input.txt", "r", stdin);
//freopen( "output.txt", "w", stdout);
cin >> M >> N;
int a, b, c, d;
cin >> a >> b >> c >> d;
a--; b--; c--; d--;
init();
return 0;
}
void init() {
vector<int> V1, V2;
vector<int> H1, H2;
char inp;
bool okv, even = false;;
while (cin >> inp) {
if (inp == 'v') {
okv = true;
continue;
}
if (inp == 'h') {
okv = false;
continue;
}
int to_push = inp - '1';
if (okv) {
if (even)
V2.push_back(to_push);
else
V1.push_back(to_push);
even = !even;
}
else {
if (even)
H2.push_back(to_push);
else
H1.push_back(to_push);
even = !even;
}
}
for (int i = 0; i < V1.size(); ++i)
V.push_back(make_pair(V2[i], V1[i]));
for (int i = 0; i < H1.size(); ++i)
H.push_back(make_pair(H2[i], H1[i]));
return;
}