SHARE
TWEET

Untitled

a guest Oct 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long n, a[2000000], w, p=0, k=0, pa, ir, ap, ak;
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  7. scanf("%d", &n);
  8. for(int f=0; f<n*2; f=f+2)
  9. {
  10.     scanf("%d", &a[f]);
  11.     scanf("%d", &a[f+1]);
  12. }
  13. sort(a, a+2*n);
  14. w=1;
  15. for(int y=0; y<2*n; y++)
  16. {
  17.     if(a[y]==a[y+1])
  18.     {
  19.         w++;
  20.     }
  21.     else
  22.     {
  23.         ir++;
  24.         if(w%2==0)
  25.         {
  26.             pa++;
  27.         }
  28.         if(w%2==0 && ap==0)
  29.         {
  30.             ap=a[y];
  31.         }
  32.         else if(w%2==0 && ak==0)
  33.         {
  34.             ak=a[y];
  35.         }
  36.  
  37.         if(w%2!=0 && p==0)
  38.         {
  39.             p=a[y];
  40.         }
  41.         else if(w%2!=0 && k==0)
  42.         {
  43.             k=a[y];
  44.         }
  45.         w=1;
  46.     }
  47. }
  48. if(p>0 && k>0)
  49. {
  50.     printf("%d ", p);
  51.     printf("%d ", k);
  52. }
  53. else if(pa==1 && p==0 && k==0)
  54. {
  55.     printf("%d ", ap);
  56.     printf("%d ", ap);
  57. }
  58. else if(pa==1 && p!=0 && k==0)
  59. {
  60.     printf("%d ", min(p, ap));
  61.     printf("%d ", max(p, ap));
  62. }
  63. else if(pa==1 && p==0 && k!=0)
  64. {
  65.     printf("%d ", min(k, ap));
  66.     printf("%d ", max(k, ap));
  67. }
  68. else
  69. {
  70.  
  71.     printf("NIE");
  72. }
  73. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top