-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspin.cpp
61 lines (56 loc) · 1.03 KB
/
spin.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
/*
ID:10179811
TASK:spin
LANG:C++
#FILE
*/
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
const int N=5,round=360;
struct Lun
{
int rotate,q,ws[6],ww[6];
}lun[5];
int cnt[round];
bool check()
{
memset(cnt,0,sizeof(cnt));
for(int i=0;i<N;++i)
for(int j=0;j<lun[i].q;++j)
for(int k=0;k<=lun[i].ww[j];++k)
++cnt[(lun[i].ws[j]+k)%round];
for(int i=0;i<round;++i)
if(cnt[i]==5)return true;
return false;
}
int main()
{
freopen("spin.in","r",stdin);
freopen("spin.out","w",stdout);
for(int i=0;i<N;++i)
{
scanf("%d %d",&lun[i].rotate,&lun[i].q);
for(int j=0;j<lun[i].q;++j)scanf("%d %d",&lun[i].ws[j],&lun[i].ww[j]);
}
int ans;
for(ans=0;ans<=round;++ans)
{
if(check())
{
printf("%d\n",ans);
//system("pause");
return 0;
}
for(int j=0;j<N;++j)
for(int k=0;k<lun[j].q;++k)
{
lun[j].ws[k]+=lun[j].rotate;
while(lun[j].ws[k]>=round)lun[j].ws[k]-=round;
}
}
printf("none\n");
//system("pause");
return 0;
}