Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // KOXEN ROBI CZARY
  4. //
  5. // Created by Dominik Smaga on 25/10/2016.
  6. // Copyright © 2016 Dominik Smaga. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <vector>
  11. #include <string>
  12. #include <climits>
  13. using namespace std;
  14.  
  15. int last=0;
  16.  
  17. struct blok{
  18. bool exist=false;
  19. int a=INT_MIN,b=INT_MAX;
  20. int oper=-1;
  21. };typedef blok blok;
  22.  
  23. int first(blok T[], int x, int X){
  24. for(int i = x; i<=last;i++){
  25. if(T[i].exist==true){
  26. return i;
  27. }
  28. }
  29. return -1;
  30. }
  31.  
  32. int select(blok T[], int x, int y, int X){
  33. int p1 = first(T,x,X);
  34. bool t;
  35. if(y-1>T[p1].a){
  36. cout << "first" << endl;
  37. t=(T, x, y+1, X, p1);
  38. if(t==true){
  39. return 0;
  40. }
  41. }
  42. if(T[p1].b > y+1){
  43. cout << "second" << endl;
  44. t=(T, x, y+1, X, p1);
  45. if(t==true){
  46. return 1;
  47. }
  48. }
  49. return 2;
  50. }
  51.  
  52. bool test(blok T[], int x, int y, int X, int p1){
  53. if(y-1>T[p1+1].a){
  54. return true;
  55. }
  56. if(T[p1+1].b > y+1){
  57. return true;
  58. }
  59. return false;}
  60.  
  61.  
  62. int main(){
  63. int X,n,i;
  64. int up=0;
  65. int TempX, TempA, TempB;
  66. cin >> n >> X;
  67. blok *T;
  68. T = new blok[X];
  69. for(i=0;i<n;i++){
  70. cin >> TempX >> TempA >> TempB;
  71. T[TempX].exist = true;
  72. T[TempX].a = TempA;
  73. T[TempX].b = TempB;
  74. if(TempX > last){
  75. last = TempX;
  76. }
  77. }
  78.  
  79. int x = 0, y = 0;
  80. int point=-1;
  81. while(x!=X && x!=last){
  82. point=select(T,x,y,X);
  83. if(point==0){
  84. y--;
  85. x++;
  86. cout << "down" << endl;
  87. }
  88.  
  89. if(point==1){
  90. y++;
  91. x++;
  92. up++;
  93. cout << "up" << endl;
  94. }
  95.  
  96. else{
  97. cout << "nope" << endl;
  98. }
  99. system("PAUSE");
  100. }
  101. cout << up;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement