ch1 : The Clocks


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*
  2.   NAME : Nursoltan
  3.   PROB : clocks
  4.   LANG : C++
  5.   DATE : 29/06/11 23:28
  6. */
  7. #include <algorithm>
  8. #include <bitset>
  9. #include <cctype>
  10. #include <cmath>
  11. #include <cstdio>
  12. #include <cstdlib>
  13. #include <cstring>
  14. #include <ctime>
  15. #include <sstream>
  16. #include <iostream>
  17. #include <map>
  18. #include <set>
  19. #include <stack>
  20. #include <utility>
  21. #include <queue>
  22.  
  23. using namespace std;
  24.  
  25. #define MAX 100
  26. #define INF INT_MAX
  27. #define eps (1e-9)
  28.  
  29. #define FOR(_i,_k,_n) for((_i)=(_k); (_i)<(_n); (_i)++)
  30. #define FORR(_i,_k,_n) for(int (_i)=(_k); (_i)>=(_n); (_i)--)
  31. #define CLR(_x) memset((_x),0,sizeof(_x))
  32. #define SQR(_x) ((_x)*(_x))
  33. #define all(_x) _x.begin(),_x.end()
  34. #define sz(_x) sizeof(_x)
  35.  
  36. #define vc vector<int>
  37. #define pb push_back
  38. #define mp make_pair
  39. #define iss istringstream
  40. #define oss ostringstream
  41. #define px first
  42. #define py second
  43.  
  44. typedef long long ll;
  45. typedef pair <int,int> point;
  46. int ABS(int _x){ return _x>0?_x:-_x; }
  47.  
  48. vector<int> b;
  49.  
  50. void proc(int i, int ordk){
  51. b[i]=b[i]+ordk*3;
  52. if(b[i]>12) b[i]%=12;
  53. }
  54.  
  55. int main()
  56. {
  57. freopen("clocks.in","r",stdin);
  58. freopen("clocks.out","w",stdout);
  59.  
  60. int k,i,j;
  61. vector<int> a(9),dest(9);
  62. FOR(i,0,9) cin>>a[i],dest[i]=12;
  63.  
  64. int ord[9]={0};
  65. FOR(ord[0],0,4) FOR(ord[1],0,4) FOR(ord[2],0,4)
  66. FOR(ord[3],0,4) FOR(ord[4],0,4) FOR(ord[5],0,4)
  67. FOR(ord[6],0,4) FOR(ord[7],0,4) FOR(ord[8],0,4){
  68. b=a;
  69. proc(0,ord[0]); proc(1,ord[0]); proc(3,ord[0]); proc(4,ord[0]);
  70. proc(0,ord[1]); proc(1,ord[1]); proc(2,ord[1]);
  71. proc(1,ord[2]); proc(2,ord[2]); proc(4,ord[2]); proc(5,ord[2]);
  72. proc(0,ord[3]); proc(3,ord[3]); proc(6,ord[3]);
  73. proc(1,ord[4]); proc(3,ord[4]); proc(7,ord[4]); proc(5,ord[4]); proc(4,ord[4]);
  74. proc(2,ord[5]); proc(5,ord[5]); proc(8,ord[5]);
  75. proc(3,ord[6]); proc(4,ord[6]); proc(6,ord[6]); proc(7,ord[6]);
  76. proc(6,ord[7]); proc(7,ord[7]); proc(8,ord[7]);
  77. proc(4,ord[8]); proc(5,ord[8]); proc(7,ord[8]); proc(8,ord[8]);
  78.  
  79. if(b==dest){
  80. int k=0;
  81. FOR(i,0,9) FOR(j,0,ord[i]){ if(k) cout<<" "; cout<<i+1; k=1; }
  82. cout<<endl;
  83. goto GOTOHELL;
  84. }
  85. }
  86.  
  87. GOTOHELL :
  88. //system("pause");
  89. return 0;
  90. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.