Combothermal

Untitled

Apr 19th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #pragma GCC optimize ("O3")
  2. #pragma GCC target ("sse4")
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. typedef long long ll;
  9. typedef long double ld;
  10. typedef complex<ld> cd;
  11.  
  12. typedef pair<int, int> pi;
  13. typedef pair<ll,ll> pl;
  14. typedef pair<ld,ld> pd;
  15.  
  16. typedef vector<int> vi;
  17. typedef vector<ld> vd;
  18. typedef vector<ll> vl;
  19. typedef vector<pi> vpi;
  20. typedef vector<pl> vpl;
  21. typedef vector<cd> vcd;
  22.  
  23. #define FOR(i, a, b) for (int i=a; i<(b); i++)
  24. #define F0R(i, a) for (int i=0; i<(a); i++)
  25. #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
  26. #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
  27.  
  28. #define sz(x) (int)(x).size()
  29. #define mp make_pair
  30. #define pb push_back
  31. #define f first
  32. #define s second
  33. #define lb lower_bound
  34. #define ub upper_bound
  35. #define all(x) x.begin(), x.end()
  36. #define ins insert
  37.  
  38. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  39.  
  40. const int MOD = 1000000007;
  41. const char nl = '\n';
  42. const int MX = 100001; //check the limits, dummy
  43.  
  44. void solve() {
  45. ll X, Y; cin >> X >> Y;
  46. string ans = "";
  47. F0Rd(cap, 36) {
  48. ll A = X, B = Y;
  49. string cur = "";
  50. F0Rd(i, cap) {
  51. if (abs(A) > abs(B) && A > 0) {
  52. cur += 'E';
  53. A -= (1ll << i);
  54. } else if (abs(A) > abs(B) && A < 0) {
  55. cur += 'W';
  56. A += (1ll << i);
  57. } else if (B > 0) {
  58. cur += 'N';
  59. B -= (1ll << i);
  60. } else {
  61. cur += 'S';
  62. B += (1ll << i);
  63. }
  64. }
  65. if (A == 0 && B == 0) {
  66. reverse(all(cur)); ans = cur;
  67. }
  68. }
  69. if (ans == "") {
  70. cout << "IMPOSSIBLE" << nl;
  71. } else {
  72. cout << ans << nl;
  73. }
  74. }
  75.  
  76. int main() {
  77. ios_base::sync_with_stdio(0); cin.tie(0);
  78.  
  79. int T; cin >> T;
  80. FOR(i, 1, T+1) {
  81. cout << "Case #" << i << ": ";
  82. solve();
  83. }
  84.  
  85. return 0;
  86. }
  87.  
  88. // read the question correctly (ll vs int)
  89. // template by bqi343
Advertisement
Add Comment
Please, Sign In to add comment