Guest User

Untitled

a guest
May 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4.  
  5. #define UNIVERSE_SIZE 4294967295
  6. #define MAX_TO_LAUNCH 1000
  7. #define MAX_ON_SPACE 100000
  8.  
  9. using namespace std;
  10.  
  11. map<long int, map<long int, int> > init(long int spLaunched[][2], long int n) {
  12.  
  13. map<long int, map<long int, int> > universe;
  14.  
  15. for( int i = 0; i < n; i++ ) {
  16. universe[spLaunched[i][0]][spLaunched[i][1]] = 1;
  17. }
  18.  
  19. return universe;
  20.  
  21. }
  22.  
  23. vector<int> solve(long int spLaunched[][2], int spToLaunch[][2], long int n, int k) {
  24. map<long int, map<long int, int> > universe = init(spLaunched, n);
  25.  
  26. vector<int> result;
  27.  
  28. for(int i = 0; i < k; i++) {
  29. int value = universe[spToLaunch[i][0]][spToLaunch[i][1]];
  30. if(value == 1) {
  31. result.push_back(0);
  32. } else {
  33. result.push_back(1);
  34. }
  35. }
  36.  
  37. return result;
  38. }
  39.  
  40. int main() {
  41.  
  42. long int n;
  43. int k;
  44.  
  45. long int input[][2] = {};
  46.  
  47. cin >> n >> k;
  48.  
  49. long int spLaunched[n][2];
  50. int spToLaunch[k][2];
  51.  
  52.  
  53. for(long int i = 0; i < n; i++) cin >> spLaunched[i][0] >> spLaunched[i][1];
  54. for(int i = 0; i < k; i++) { cin >> spToLaunch[i][0] >> spToLaunch[i][1];}
  55.  
  56.  
  57. vector<int> result = solve(spLaunched, spToLaunch, n, k);
  58.  
  59. for(int i = 0; i < k; i++) {
  60. cout << result[i] << endl;
  61. }
  62.  
  63. return 0;
  64. }
Add Comment
Please, Sign In to add comment