-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (52 loc) · 1.16 KB
/
main.cpp
File metadata and controls
65 lines (52 loc) · 1.16 KB
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
#include <fstream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
int main(int argc, char** argv)
{
ifstream finIn(argv[1]);
ifstream fin1(argv[2]);
ifstream fin2(argv[3]);
int n1, n2;
fin1 >> n1;
fin2 >> n2;
if (n1 != n2)
{
cout << "Wrong count of resources";
return 1;
}
map<int, map<int, std::map<int, int>>> r1;
map<int, map<int, std::map<int, int>>> r2;
for (int i = 0; i < n1; i++)
{
float x1, y1;
float x2, y2;
int id1, id2;
fin1 >> x1 >> y1 >> id1;
fin2 >> x2 >> y2 >> id2;
int rx1, ry1, rx2, ry2;
rx1 = round(x1 - 0.5f);
ry1 = round(y1 - 0.5f);
rx2 = round(x2 - 0.5f);
ry2 = round(y2 - 0.5f);
r1[rx1][ry1][id1]++;
r2[rx2][ry2][id2]++;
}
for (const auto& ys : r1)
{
for (const auto& cnts: ys.second)
{
for (const auto& id : cnts.second)
{
if (!r2.count(ys.first) || !r2[ys.first].count(cnts.first) || !r2[ys.first][cnts.first].count(id.first) || r2[ys.first][cnts.first][id.first] != id.second)
{
cout << "Resource " << id.second << " at position " << ys.first + 0.5f << ", " << cnts.first + 0.5f << " is not found";
return 1;
}
}
}
}
return 0;
}