-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc1615_time.cpp
61 lines (52 loc) · 1.93 KB
/
aoc1615_time.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
/* ************************************************************************** */
/* */
/* \\ /`/`` */
/* ~\o o_ 0 0\ */
/* / \__) (u ); _ _ */
/* / \/ \/ / \ \/ \/ \ */
/* /( . . ) ( )\ */
/* / \_____/ \_______/ \ */
/* [] [] [[] [[] *. */
/* []] []] [[] [[] */
/* */
/* ****************************************************************** nuo *** */
#include "iostream"
#include "vector"
using namespace std;
int find_pos(vector<pair<int, int>>);
int main()
{
vector<pair<int, int>> E;
string s;
int t, x, y;
while (getline(cin, s))
{
sscanf(s.c_str(),
"Disc #%d has %d positions; at time=0, it is at position %d.\n",
&x, &x, &y);
E.push_back(make_pair(x, y));
}
x = find_pos(E);
E.push_back(make_pair(11, 0));
y = find_pos(E);
cout << "Star 1: " << x << endl;
cout << "Star 2: " << y << endl;
return 0 ;
}
int find_pos(vector<pair<int, int>> E)
{
bool good;
int i, x;
i = 0;
while (++i)
{
x = -1;
good = true;
while (++x < E.size())
{
if ((E[x].second + i + x+1) % (E[x].first)) good = false;
}
if (good) break;
}
return (i);
}