Advertisement
Saleh127

CF 1408A

Sep 30th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll a[1000],c[1000],d[1000],e,f,i,j,k,l;
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11. ///!}@]
  12.  
  13. test
  14. {
  15.  
  16. cin>>e;
  17. for(i=0; i<e; i++)
  18. {
  19. cin>>a[i];
  20. }
  21. for(i=0; i<e; i++)
  22. {
  23. cin>>c[i];
  24. }
  25. for(i=0; i<e; i++)
  26. {
  27. cin>>d[i];
  28. }
  29. cout<<a[0]<<" ";
  30. f=a[0];
  31. for(i=1; i<e; i++)
  32. {
  33. if(i==e-1)
  34. {
  35. j=a[0];
  36. if(a[i]==f || a[i]==j)
  37. {
  38. if(c[i]==f || c[i]==j)
  39. {
  40. cout<<d[i]<<" ";
  41. f=d[i];
  42. }
  43. else
  44. {
  45. cout<<c[i]<<" ";
  46. f=c[i];
  47. }
  48. }
  49. else
  50. {
  51. cout<<a[i]<<" ";
  52. f=a[i];
  53. }
  54. }
  55. else
  56. {
  57. if(a[i]==f)
  58. {
  59. if(c[i]==f)
  60. {
  61. cout<<d[i]<<" ";
  62. f=d[i];
  63. }
  64. else
  65. {
  66. cout<<c[i]<<" ";
  67. f=c[i];
  68. }
  69. }
  70. else
  71. {
  72. cout<<a[i]<<" ";
  73. f=a[i];
  74. }
  75. }
  76. }
  77. cout<<endl;
  78. }
  79.  
  80.  
  81.  
  82. return 0;
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement